Advertisement
jimklimov

Jenkins pipeline scripted parallels

Jul 2nd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /* Example from "alcohol" on Jenkins IRC 2019-07-02
  2. * Also mentioned https://devops.stackexchange.com/questions/986/how-to-build-a-complex-parallel-jenkins-pipeline
  3. */
  4.  
  5. stage('update playgrounds') {
  6. String[] playgrounds = sh(
  7. script: "kubectl get namespace --selector playground/frontend=${branch} --output jsonpath='{.items[*].metadata.name}'",
  8. returnStdout: true
  9. ).trim().split()
  10.  
  11. Map mapped = playgrounds.collectEntries { String namespace ->
  12. ["${namespace}": {
  13. stage ("update ${namespace}") {
  14. sh """
  15. bunch of commands to update a playground
  16. """.stripIndent()
  17.  
  18. playgroundUpdated(namespace.replaceAll('playground-', ''), env.BRANCH_NAME, commit)
  19. }
  20. }]
  21. }
  22.  
  23. mapped['failFast'] = true;
  24.  
  25. parallel mapped
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement