cache
buld:
script: build
cache:
paths:
- target/*.jar
#设置key可以解决cache被覆盖
cache:
paths:
- my/files
build:
script:
- echo "build"
cache:
key: build
paths:
- target/
files: 文件发生变化自动重新生成缓存(files最多指定两个文件),提交时检查指定文件.根据指定的文件生成秘钥计算SHA检验和,如果文件未发生改变值为default.
cache:
key:
files:
- Gemfile.lock
- package.json
paths:
- vendor/ruby
- node_modules
prefix: 允许给定prefix的值与指定文件生成的秘钥组合
cache:
key:
files:
- Gemfile.lock
prefix: ${CI_JOB_NAME}
paths:
- vendor/ruby
rspec:
script:
- bundle exec rspec
默认: 在执行时开始下载文件,并在结束时重新上传文件/
policy: pull 跳过下载步骤, policy: push 跳过上传下载步骤
before_script:
- echo "before_script!!!"
variables:
DOMAIN: example.com
cache:
paths:
- target/
stages:
- build
- test
- deploy
build:
before_script:
- echo "before_script in build job"
stage: build
tags:
- build
only:
- master
script:
- ls
- id
- mvn clean package -DskipTests
- ls target
- echo "$DOMAIN"
- false && true ; exit_code=$?
- if [ $exit_code -ne 0 ]; then echo "Previous command failed"; fi;
- sleep 2;
after_script:
- echo "after_script in build job"
unittes:
stage: test
tags:
- build
only:
- master
script:
- echo "run test"
- echo 'test' >> a.txt
- ls target
retry:
max: 2
when:
- script_failure
deploy:
stage: deploy
tags:
- build
only:
- master
script:
- echo "run deploy"
- ls target
retry:
max: 2
when:
- script_failure
after_script:
- echo "after_script"