Last active
November 21, 2018 08:00
-
-
Save yangvipguang/4934f7fb916fdda2faa59c988fddb88a to your computer and use it in GitHub Desktop.
Jenkins-pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1、Dokcer 环境 | |
//2、切换workspace | |
//3、分配node 节点执行任务 | |
pipeline { | |
//agent { | |
// node{ | |
// label 'node2' | |
// customWorkspace '/tmp' | |
// } | |
// } | |
agent { | |
docker {image 'node:6.3' | |
label 'node' | |
customWorkspace '/opt/test' | |
} | |
} | |
stages { | |
stage('build') { | |
steps { | |
sh 'npm --version' | |
sh 'pwd' | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1、agent node (分配节点、自定义工作区) | |
//2、pipeline 中如何定义Maven等工具 | |
//3、script 中定义Mavne | |
def mvnHome | |
然后在stage 中定义 | |
mvnHome=tool M3(名称) | |
pipeline { | |
agent { | |
node{ | |
label 'master' | |
customWorkspace '/home/Git-Data' | |
} | |
} | |
tools { | |
maven 'M3' | |
} | |
stages { | |
stage('Preparation') { // for display purposes | |
// Get some code from a GitHub repository | |
steps{ | |
git 'XXXXXX' | |
} | |
} | |
stage('Build') { | |
steps { | |
sh 'pwd' | |
// Run the maven build | |
sh "mvn -Dmaven.test.failure.ignore clean package -Puat" | |
//sh 'mvn --version' | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent { | |
node{ | |
label 'master' | |
customWorkspace '/dataspace/Git-Data' | |
} | |
} | |
tools { | |
maven 'M3' | |
} | |
environment { | |
service = "${params.CHOICE}" | |
} | |
parameters { | |
choice(name: 'CHOICE', choices: ['a','b','c'], description: 'Pick something') | |
} | |
stages { | |
stage('Preparation') { // for display purposes | |
// Get some code from a GitHub repository | |
steps{ | |
git 'XXXXX' | |
} | |
} | |
stage('Build') { | |
steps { | |
sh 'pwd' | |
// Run the maven build | |
sh "sed -i 's/inner/outer/g' pom.xml" | |
sh "mvn -Dmaven.test.failure.ignore clean package -Puat" | |
sh 'mvn --version' | |
//echo "Choice: ${params.CHOICE}" | |
// ./deploy.sh "${params.CHOICE}" | |
sh './deploy.sh $service' | |
//sh 'echo $service' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment