参考 Gitlab部署CI并使用.gitlab-ci.yml配置您的作业(中文翻译)
.gitlab-ci.yml 配置文件详解
stages:
- code_scan
- package
- deploy
variables:
MAVEN_CLI_OPTS: "-Djib.to.auth.username=${REGISTRY_USER} -Djib.to.auth.password=${REGISTRY_PASSWORD}"
CONTENT: 'Content-Type: application/json'
...
job_code_scan:
image: registry.xxxx.com/xxxx/codescan:latest
stage: code_scan
script:
- /opt/code_scan/code_scan.sh
when: manual
tags:
- k8s
only:
- master
package: &package_tmp
image: registry.xxxx.com/gitlabci/maven:3.6.3-jdk-8
stage: package
tags:
- k8s
script:
- mvn $MAVEN_CLI_OPTS clean deploy -Pregistry -Djavacpp.platform=linux-x86_64 -DskipTests -U --settings .m2/settings.xml | tee mvn.log
artifacts:
paths:
- mvn.log
only:
- master
deploy_to_devops:
image: registry.xxxx.com/gitlabci/k8s-kubectl:v2.1.1
stage: deploy
script:
- 脚本
when: on_success
only:
- master