文档首页> 云容器引擎 CCE> 最佳实践> DevOps> Jenkins安装部署及对接SWR和CCE集群> 参考:一个完整的镜像构建、push、部署的pipeline脚本
更新时间:2022-05-07 GMT+08:00
分享

参考:一个完整的镜像构建、push、部署的pipeline脚本

镜像构建、push、部署的pipeline脚本如下:

node('slave'){ 
       stage('Clone') { 
              echo "1.Clone Stage" 
              git url: "https://github.com/lookforstar/jenkins-demo.git" 
              script { 
                     build_tag = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim() 
              } 
       } 
       stage('Test') { 
       echo "2.Test Stage" 
       } 
       stage('Build') { 
              echo "3.Build Docker Image Stage" 
              sh "docker build -t swr.cn-east-3.myhuaweicloud.com/batch/jenkins-demo:${build_tag} ." 
       } 
       stage('Push') { 
              echo "4.Push Docker Image Stage" 
              sh "docker login -u cn-east-3@82EFQWQMJWSDOYS9BQNM -p 71b0cceac30a10b99a960360b2e1deb04ec2f1bb00e88bc5eb69f3e9fd6a6d08 swr.cn-east-3.myhuaweicloud.com" 
              sh "docker push swr.cn-east-3.myhuaweicloud.com/batch/jenkins-demo:${build_tag}" 
       } 
          stage('Deploy') {
        echo "5. Deploy Stage"
        echo "This is a deploy step to test"
        sh "sed -i 's/<BUILD_TAG>/${build_tag}/' *.yaml"
        sh "cat *.yaml"
        echo "begin to config kubenetes"
        try { 
         kubernetesDeploy(
             kubeconfigId: "mogujie-spark-zxx",
             configs: "k8s.yaml")
         println "hooray, success"
        } catch (e) {
            println "oh no! Deployment failed! "
            println e
        }
        }
}
分享:

    相关文档

    相关产品

关闭导读