fix(cicd): 部署 stage 加远程 docker login Harbor
与 portal 同款修复:Harbor 私有仓库 cd-target pull 需先登录。 withCredentials 拿 harbor-credentials,ssh 传到远程执行 docker login(stdin 传密码,不进 history)。
This commit is contained in:
parent
8345c478c8
commit
598e2a3b25
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@ -46,13 +46,16 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
try {
|
try {
|
||||||
sh """
|
withCredentials([usernamePassword(credentialsId: "harbor-credentials", usernameVariable: "HUSER", passwordVariable: "HPASS")]) {
|
||||||
ssh -o StrictHostKeyChecking=accept-new ${DEPLOY_HOST} '
|
sh """
|
||||||
sudo docker pull ${IMAGE}:latest
|
ssh -o StrictHostKeyChecking=accept-new ${DEPLOY_HOST} "
|
||||||
sudo docker rm -f buildflow-api 2>/dev/null || true
|
echo '${HPASS}' | sudo docker login ${HARBOR} -u ${HUSER} --password-stdin
|
||||||
sudo docker run -d --name buildflow-api --restart unless-stopped -p ${APP_PORT}:${APP_PORT} ${IMAGE}:latest
|
sudo docker pull ${IMAGE}:latest
|
||||||
'
|
sudo docker rm -f buildflow-api 2>/dev/null || true
|
||||||
"""
|
sudo docker run -d --name buildflow-api --restart unless-stopped -p ${APP_PORT}:${APP_PORT} ${IMAGE}:latest
|
||||||
|
"
|
||||||
|
"""
|
||||||
|
}
|
||||||
echo "部署完成"
|
echo "部署完成"
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
echo "警告:部署节点 ${DEPLOY_HOST} 暂不可用,跳过自动部署(镜像已推送 Harbor)。原因:${e.getMessage()}"
|
echo "警告:部署节点 ${DEPLOY_HOST} 暂不可用,跳过自动部署(镜像已推送 Harbor)。原因:${e.getMessage()}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user