Pipeline流水线 自动脚本
Pipeline流水线脚本样板:
pipeline {
agent any
stages {
stage('pull code') {
steps {
echo 'pull code'
}
}
stage('build project') {
steps {
echo 'build project'
}
}
stage('publish project') {
steps {
echo 'public project'
}
}
}
}
步骤:
新建Item-->Pipline
Pipeline-->Pipline script-->(try sample Pipeline)Hello World-->(流水线语法)获取脚本:
1、pull code/steps部分
流水线语法:
1)checkout:Check out from version control
2)SCM:Git
Repository URL:http://192.168.1.100:82(Gitlab服务器地址)
Credentials: root-auth-ssh
3)生成流水线脚本
4)复制脚本 粘贴到 pipeline脚本中 steps/pull code部分
2、build project/steps部分
流水线语法:
1)sh:Shell Script
2)Shell Script: mvn clean package
3)生成流水线脚本
4)复制脚本 粘贴到 pipeline脚本中 steps/build project部分
3、publish project/steps部分
流水线语法:
1)deploy:Deploy war/ear to a container
2)WAR/EAR file——target/*.war
3)Tomcat 8.x Remote/Credentials:xxx Tomcat URL
4)生成流水线脚本
5)复制脚本 粘贴到 pipeline脚本中 steps/publish project部分
pipeline {
agent any
stages {
stage('pull code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: '37f6cba9-628e-4a81-a5bd-b415651d3863', url: 'git@192.168.80.130:hrdev_group01/web_demo.git']]])
}
}
stage('build project'){
steps {
sh 'mvn clean package'
}
}
stage('publish project'){
steps {
deploy adapters: [tomcat8(credentialsId: 'e38c1f60-e81d-4595-a630-bf86404820c5', path: '', url: 'http://192.168.80.161:8080')], contextPath: null, war: 'target/*.war'
}
}
}
}

浙公网安备 33010602011771号