-
Choerodon平台版本:0.7.0
-
运行环境(如localhost或k8s):centos7 k8s
-
遇到问题时的前置条件:
-
问题描述:
can’t stat ‘target/app.jar’: No such file or directory在结束feature分支触发ci流水线时报错
下面是我的.gitlab-ci.yml文件
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