-
Choerodon平台版本:0.7.0
-
运行环境(如localhost或k8s):k8s
-
遇到问题时的前置条件:持续集成通过
-
报错信息(请尽量使用代码块的形式展现):
下面是gitlab.ci文件
image: registry.cn-hangzhou.aliyuncs.com/choerodon-tools/cibase:0.5.0
stages:
- mvn-package
- docker-build
maven-test-branches:
stage: mvn-package
script:
- git_merge develop
- mvn package -U -DskipTests=false
only:
- branches
except:
- master
- tags
- develop
- /^release-.*$/
- /^hotfix-.*$/
maven-test-build:
stage: mvn-package
script:
- update_pom_version
- mvn package -U -DskipTests=false
# - mvn --batch-mode verify sonar:sonar -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.analysis.serviceGroup=$GROUP_NAME -Dsonar.analysis.commitId=$CI_COMMIT_SHA
- mkdir -p /cache/${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
- cp target/app.jar /cache/${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}/app.jar
only:
- tags
- develop
- /^release-.*$/
- /^hotfix-.*$/
docker-build:
stage: docker-build
script:
- docker_build
- chart_build
only:
- tags
- develop
- /^release-.*$/
- /^hotfix-.*$/
.auto_devops: &auto_devops |
curl -o .auto_devops.sh \
"${CHOERODON_URL}/devops/ci?token=${Token}&type=microservice"
if [ $? -ne 0 ];then
cat .auto_devops.sh
exit 1
fi
source .auto_devops.sh
function docker_build(){
cp /cache/${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}/app.jar ${1:-"src/main/docker"}/app.jar || true
docker login -u ${DOCKER_USER} -p ${DOKCER_PWD} ${DOCKER_REGISTRY}
docker build --pull -t ${DOCKER_REGISTRY}/${GROUP_NAME}/${PROJECT_NAME}:${CI_COMMIT_TAG} ${1:-"src/main/docker"}
docker push ${DOCKER_REGISTRY}/${GROUP_NAME}/${PROJECT_NAME}:${CI_COMMIT_TAG}
rm -rf /cache/${CI_PROJECT_NAME}-${CI_PROJECT_ID}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
}
before_script:
- *auto_devops