码迷,mamicode.com
首页 > 其他好文 > 详细

Jenkins中管道案例脚本(声明式语法)

时间:2020-04-12 18:50:14      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:案例   color   roo   min   param   from   lse   test   echo   

 

pipeline {
    agent any

    parameters {
        choice(
            choices: feature\nmaster\npercent10,
            description: 选择要发布的分支,默认是feature,
            name: deploy_branch
        )

        choice(
            choices: service\ncontroller\nadmin-web,
            description: 选择要发布的服务,默认是controller,
            name: deploy_service
        )

    }

    stages {
        stage ("Git") {
            steps {
                  // Get some code from a GitHub repository
                  //sh "echo test-auto-release"
                  script {
                      manager.addShortText("分支:"+manager.envVars[deploy_branch])
                      manager.addShortText("服务:"+manager.envVars[deploy_service])
                  }
                  sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh git-jmucai ${deploy_branch}"
            }
        }


        stage ("Build") {
            steps {
                    // Run the maven build
                    //sh "echo test-auto-release"
                    sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh mvn-jmucai"

            }
        }


        stage ("Copy") {
            steps {
                  // Copy file to server
                  script {
                      if ( deploy_service == service) {
                          sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh copy-jmucai service IP3 jmucai-hc-pro-core.pem"
                      } else if ( deploy_service == controller) {
                          sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh copy-jmucai controller IP2 jmucai-hc-pro-core.pem"
                        } else if ( deploy_service == admin-web) {
                          sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh copy-jmucai admin-web IP2 jmucai-hc-pro-core.pem"
                        }
                        
                  }

            }
        }


        stage ("Issu") {
            steps {
                // Update
                script {
                  if ( deploy_service == service) {
                    sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh issu-jmucai service IP3 jmucai-hc-pro-core.pem"

                  } else if ( deploy_service == controller) {
                    sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh issu-jmucai controller IP2 jmucai-hc-pro-core.pem"
                    } else if ( deploy_service == admin-web) {
                    sh ssh -i /opt/.scripts/jmu-hc-pro-jump.pem -o StrictHostKeyChecking=no root@IP "sh /opt/jenkins/opt/.scripts/test-auto-release.sh issu-jmucai admin-web IP2 jmucai-hc-pro-core.pem"
                    }
                 }
                }
            }
    }

}

 

Jenkins中管道案例脚本(声明式语法)

标签:案例   color   roo   min   param   from   lse   test   echo   

原文地址:https://www.cnblogs.com/jmucai/p/12686481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!