Jenkins

来自ling
跳转至: 导航搜索

pipline

pipeline { 
   agent any 
   stages { 
      stage('拉取代码') { 
          steps { 
             checkout([$class: 'GitSCM', branches: [[name: '${tag}']], extensions: [], userRemoteConfigs: [[credentialsId: '100b584e-7f67-466f-8b93-9b9038e117a0', url: 'https://git.ibimfish.cn/Suzhou/pond.git']]])
            } 
        }
    //   stage('切换分支') {
    //         steps {
    //             echo '开始拉release-test分支.....'
    //             git branch: "release-test",credentialsId: '100b584e-7f67-466f-8b93-9b9038e117a0', url: 'https://git.ibimfish.cn/Suzhou/pond.git'
    //         }
	// 	}
      stage('编译打包') { 
             steps { 
              sh 'mvn  clean package install -Dmaven.test.skip=true -DarchetypeCatalog=local'
            } 
        } 
      stage('拷贝jar包') { 
             steps { 
             sh 'ansible tomcat -m copy -a  "src=/root/.jenkins/workspace/pipeline-pond/pond/target/pond.jar  dest=/root/upload/"'
            } 
        } 
      stage('启动脚本') { 
             steps { 
             sshPublisher(publishers: [sshPublisherDesc(configName: '192.168.2.204', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''cd /pipeline-pond
source /etc/profile
bash up.sh

''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '', usePty: true)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
            } 
        }                    
   }
}