# **此处根据自身项目需求选择对应的镜像版本(需要开发修改)**
image: chegva.com/online/ci:maven-jdk-8-onbuild
stages:
- build
# 为了加快打包速度,cache 功能可能对你非常有用
cache:
key: "$CI_PROJECT_ID"
untracked: true
paths: # 添加需要cache的目录
- deploy
- .local
- .m2
- node_modules
# 线上环境(名字可以自己定义,例如:"online-build","online"等)
online-build:
stage: build
script:
# 请根据自己项目,修改构建命令
# 如果项目引用了第三方项目,例如:SOA,可以直接git clone下该项目
# 注意:仓库地址,必须是https的git地址
# 例如:git clone https://chegva.com/xxxxxx.git
- mvn -U clean package
only:
- tags
artifacts:
# 发布时,会以target的下级目录为根目录发布,如下:只发布*.war文件
paths:
- target/*.war
untracked: false
# 测试环境
test-build:
stage: build
script:
# 请根据自己项目,修改构建命令
- mvn -U clean package
only:
- tags
artifacts:
# 发布时,会以target的下级目录为根目录发布,如下:只发布*.war文件
paths:
- target/*.war
untracked: false
2. Go
image: chegva.com/online/ci:golang-1.9.2-onbuild
stages:
- build
online-build:
stage: build
script:
- /bin/bash -x code_build.sh
artifacts:
paths:
- target/*
untracked: false
# code_build.sh
#!/bin/bash
export program=test
export workspace=$(pwd)
mkdir -p $GOPATH/src/chegva.com/site/
cd ../
cp -r test $GOPATH/src/chegva.com/site/
cd $GOPATH/src/chegva.com/site/test
glide install
go build -i -o ./bin/$program ./main
cp -r ./bin $workspace/target/
3. Nodejs
image: chegva.com/online/ci:node-v9.0-onbuild
cache:
untracked: false
key: "$CI_PROJECT_ID"
paths:
- node_modules
stages:
- build
build:
stage: build
script:
- mkdir -p target && rm -rf target/*
- PHANTOMJS_CDNURL=http://chegva.com/public CHROMEDRIVER_CDNURL=https://npm.taobao.org/mirrors/chromedriver npm install --registry=https://rnpm.chegva.com --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
- npm run dist
- mv public/* target/
only:
- tags
artifacts:
paths:
- target/*
untracked: false
# -----------------nodejs---------------
image: chegva.com/online/centos63:base
cache:
untracked: false
key: "$CI_PROJECT_NAME"
paths:
- local
- node_modules
variables:
NODE_PATH: "./local/node/bin"
PATH: "$NODE_PATH:$PATH"
stages:
- build
build:
stage: build
before_script:
- bin/install-node
- npm i -g inherits
script:
- tar zxf rocket.chat.tgz
- mv bundle rocket-chat
- cd Rocket.Chat/programs/server
- npm i
- cd ../..
only:
- tags
after_script:
- rm -rf _$CI_PROJECT_NAME
- rsync -a --delete --exclude={.local,.git} . ../_$CI_PROJECT_NAME
- mv ../_$CI_PROJECT_NAME ./
artifacts:
paths:
- rocket-chat/*
untracked: false
4. Ruby
before_script:
- apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
- ruby -v
- which ruby
- gem install bundler --no-ri --no-rdoc
- bundle install --jobs $(nproc) "${FLAGS[@]}"
rspec:
script:
- bundle exec rspec
rubocop:
script:
- bundle exec rubocop
# 定义了两个jobs,rspec和rubocop(名字可以随便取),他们执行不同的命令。在每个jobs之前,before_script定义的命令都将会被执行。