"Environment Variables" view for jenkins pipeline job "Environment Variables" view for jenkins pipeline job jenkins jenkins

"Environment Variables" view for jenkins pipeline job


Add this code in your pipeline to view variables at runtime

  • For linux

     sh 'env > env.txt' for (String i : readFile('env.txt').split("\r?\n")) {     println i }
  • For windows

    bat 'set > env.txt' for (String i : readFile('env.txt').split("\r?\n")) {    println i}


I also was surprised there's no Environment variables view. Anyhow this is simpler than a loop:

    stage("Env Variables") {        steps {            sh "printenv"        }    }

Or in simple scripting syntax, with sorted output:

    stage('env') {         sh 'printenv|sort'    }


You can use this

 sh "env | sort"