def call(Map config) {
node('terraform-slave') { cleanWs() checkout scm
stage('Plan') { commitChangeset = sh(returnStdout: true, script: 'git diff-tree --no-commit-id --name-only -r HEAD').trim() } stage('EchoToVerify') { tfvars = commitChangeset.replaceAll("terraform.tfvars", "") echo tfvars } stage('Loop') { loop(tfvars) } }}
def loop(list) { list.each { sh "(cd ${it}; cat terraform.tfvars)" }}
def loop(list) { for (dir in [list]) { sh "(cd ${it}; cat terraform.tfvars)" }}Hi
commitChangeset = sh( ... ).trim() will return string. You should
transform it to list, for example:
commitChangeset = sh( ... ).trim().tokenize(",") where delimiter is ","
And then no need to replace "," by " " in
tfvars =
commitChangeset.replaceAll("terraform.tfvars", "")
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3b411f4a-56f4-4c04-a9a4-6fde13f2239e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- WBD, Viacheslav Dubrovskyi