jenkins pipline

https://www.jenkins.io/zh/doc/pipeline/tour/hello-world/

https://www.jianshu.com/p/f1167e8850cd

maven项目jenkinsfile

目标是n多个maven项目公用一个jenkins模板文件,然后通过改环境变量的方式去发版

pipeline {
   agent any
   environment  {
        git = "http://xx"
        catalog = 'test'
        subpath = 't'
        jar = ''
        ip = ''
        port = ''
        jvm = " -jar /root/$subpath/target/$jar --server.port=$port"
        cmd = 'curl -s http://master/cds/service/run.sh | sh -x -s restart "$jvm"'
    }

   tools {
      maven "maven"
   }

   stages {
      stage('Build') {
         steps {
            git credentialsId: '', poll: false, url: "$git"
            sh "mvn clean package -P$catalog -pl $subpath -am -Dmaven.test.skip=true"
         }

         post {
            success {
               archiveArtifacts "$subpath/target/$jar"
               sshPublisher(publishers: [sshPublisherDesc(configName: "$ip", transfers: [sshTransfer(execCommand:"$cmd", sourceFiles: "$subpath/target/$jar")])])}
         }
      }
   }
}

  

原文地址:https://www.cnblogs.com/jabbok/p/12881074.html