qdyxmas's Room

Done is better than perfect...

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}")
      }  
    }
  }
}

1 评论

  1. Julieta
    /回复

    I have been surfing online more than three hours today, yet I never found any interesting article like yours. It?s pretty worth enough for me. Personally, if all web owners and bloggers made good content as you did, the net will be much more useful than ever before. https://bestbarbershopmontreal.com

评论