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

Jenkins Pipline语法

时间:2018-06-11 11:56:54      阅读:1042      评论:0      收藏:0      [点我收藏+]

标签:ide   tps   region   python   info   remote   hang   choices   ext   

引用自:http://baijiahao.baidu.com/s?id=1582812185263227836&wfr=spider&for=pc

引用自:https://www.cnblogs.com/YatHo/p/7856556.html

一、多参数选择

pipeline{
agent {
label ‘192.168.0.156‘
}
parameters{
choice(name:‘test‘,
choices:‘test_a\ntest_b‘,
description:‘this is test‘)
}
environment{
b = "/bbb"
}
stages{
stage(‘阶段1‘){
steps{
script{
a = "/home"
sh "pwd"
sh "echo \"test1\""
sh "echo ${test}"
}
}
}
stage(‘阶段2‘){
steps{
script{
sh "echo \"test2\""
sh "echo ${a}"
sh "echo ${b}"
}
}
}
stage(‘阶段3‘){
steps{
script{
sh "echo \"test3\""
}
}
}
stage(‘阶段4‘){
steps{
script{
sh "echo \"test4\""
}
}
}
}
}

2、单参数选择

pipeline {

agent {
label ‘192.168.0.156‘
}

options {
timeout(time: 30, unit: ‘MINUTES‘)
}

parameters {
//构建选项,选择构建环境
choice(name: ‘release_env‘,
choices:‘pro‘,
description: ‘choose release environment\nserver:47.98.172.183\npro port:4564‘)
}

stages {

stage(‘准备源码‘) {
steps {
script {
// 类似项目执行更改以下两个参数
svn_addr="svn://192.168.0.151/pycf/Projects/fof2.0/fof2.0-product_daily_data"
module_name="product_daily_data"

workdir="/application/docker_hub/java/fof2"
project_name="fof2"
r_env=release_env
docker_file_path="${workdir}/${module_name}_${r_env}"
docker_compose_file="${workdir}/docker-compose-${r_env}.yml"
docker_compose_module_name="${project_name}_${module_name}_${r_env}"
}
checkout([$class: ‘SubversionSCM‘,
additionalCredentials: [],
excludedCommitMessages: ‘‘,
excludedRegions: ‘‘,
excludedRevprop: ‘‘,
excludedUsers: ‘‘,
filterChangelog: false,
ignoreDirPropChanges: false,
includedRegions: ‘‘,
locations: [[credentialsId: ‘dffd18a8-473e-477e-a4dc-4d528fa3e55c‘,
depthOption: ‘infinity‘,
ignoreExternalsOption: true,
local: ‘.‘,
remote: svn_addr ]],
quietOperation: true,
workspaceUpdater: [$class: ‘UpdateUpdater‘]])
}
}

stage(‘构建运行‘) {
steps {
sh "mkdir -p ${docker_file_path}; rm -rf ${docker_file_path}/*"
sh "/bin/cp -a ./* ${docker_file_path};"

sh "echo ‘svn url: ${svn_addr}‘ > ${docker_file_path}/README.txt"
sh "svn upgrade . &> /dev/null||echo &> /dev/null"
sh "export LANG=en_US.UTF-8;svn info . 2>/dev/null|grep -i Revision|awk ‘{print \"svn revision: \"\$2}‘ >> ${docker_file_path}/README.txt"
sh "echo ‘jenkins job: ${env.JOB_NAME}‘ >> ${docker_file_path}/README.txt"
sh "echo ‘jenkins build env: ${r_env}‘ >> ${docker_file_path}/README.txt"
sh "echo ‘jenkins build number: ${env.BUILD_NUMBER}‘ >> ${docker_file_path}/README.txt"

sh "cd /application/docker_hub/fof2.0-deploy/;/usr/bin/python main.py 10 yes;"
}
}

stage(‘等待30s检查业务‘) {
steps {
script {
sh "sleep 30;"
sh " cd /application/docker_hub/fof2.0-deploy/;/usr/bin/python check.py ${docker_compose_module_name};"
}
}
}

}
}

Jenkins Pipline语法

标签:ide   tps   region   python   info   remote   hang   choices   ext   

原文地址:https://www.cnblogs.com/Presley-lpc/p/9166223.html

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