Skip to content

Instantly share code, notes, and snippets.

@ftorto
Created October 11, 2017 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftorto/540551efce6984ebfd5ec7fd762fbb93 to your computer and use it in GitHub Desktop.
Save ftorto/540551efce6984ebfd5ec7fd762fbb93 to your computer and use it in GitHub Desktop.
Parallelize tasks #jenkins #pipeline
  for (i = 0; i < sources.length; i++){
    String source = sources[i]
    String contrib_url = source.split(" ")[0]
    String contrib_tag = source.split(" ")[1]
    String contrib_dest_path = i.toString().padLeft(4,'0') + "__" + contrib_url.split('/').last() + "__" + contrib_tag
    builders[contrib_dest_path] = {
      echo "\u2600 Pulling [${contrib_url}] using tag [${contrib_tag}] to [${contrib_dest_path}]"
      checkout([$class: 'GitSCM', branches: [[name: "refs/tags/"+contrib_tag]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: contrib_dest_path]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: credentials, url: contrib_url]]])
    }
    parallel builders
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment