pipeline语法汇总
def services_to_build = params.services.split(',');
pipeline {
agent any
stages {
stage("start") {
steps {
echo ("拉取${params.services}代码");
}
}
stage("update code") {
steps {
script {
for (i = 0; i < services_to_build.size(); i++) {
def service = services_to_build[i];
echo ("开始拉${service}的代码");
dir("${service}") {
echo ("service=${service}的代码");
git branch: "${source_branch}", credentialsId: 'xxxxxxxxxxxx', url: "https://git.xkool.org/xkool/${service}.git" ;
//checkout 目的分支
checkout([$class: 'GitSCM', branches: [[name: "${target_branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "${target_branch}"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'xxxxxxxxxxxx', url: "https://git.xkool.org/xkool/${service}.git"]]]);
}
}
}
}
}
stage("compare branch") {
steps {
sh("python3 diff_branch.py ${source_branch} ${target_branch}")
}
}
}
}