jenkins pipeline获取Harbor镜像作为参数
需要用到Image Tag Parameter插件
通过docker镜像实现pipeline回滚
壯陽藥
844″ src=”https://img.ziji-cn-hangzhou.dnsjia.com/2020/04/image-4.png” alt=”” width=”553″ height=”691″ />
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}'`")
}
}
}