jenkins pipeline获取Harbor镜像作为参数
需要用到Image Tag Parameter插件
通过docker镜像实现pipeline回滚
node{
.....
if ("${env.DEPLOY_FLAG}" == 'Deploy'){
........
}
if ("${DEPLOY_FLAG}" == 'Rollback'){
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s-kubectl', namespace: 'jenkins', serverUrl: 'https://kubernetes.default.svc.cluster.local') {
sh("kubectl set image deployment/${project} ${appName}=harbor.xxx.xxx/${DOCKER_IMAGE} -n ${namespace}")
sh ("kubectl rollout status -n $namespace deployment/${project}")
sh("echo 请访问: http://`kubectl get ingress -n ${namespace} ${appName} -o jsonpath='{.spec.rules[].host}'`")
}
}
}