I am wanting to pass variables between stages in a Jenkinsfile and am doing it as people suggest, by writing to a file then parsing it.
stage('1') {
steps {
sh "echo value > var.txt"
script {
VALUE = readFile('var.txt')
}
}
}
stage('2') {
steps {
sh "echo ${VALUE} && echo 'ok'"
}
}
However, I am getting some form of new line character at the end of ${VALUE} that means I am trying to execute 2 lines and the && is causing the stage to barf. I've tried piping through tr -d '\r\n'but it doesn't seem to do anything.