Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54047

All boolean parameters get set to true when used to set env vars.

XMLWordPrintable

      Using boolean parameters to set environment variables doesn't work for some crazy reason.

      pipeline {
          agent none
          options {
              ansiColor('xterm')
              skipDefaultCheckout()
              durabilityHint('PERFORMANCE_OPTIMIZED')
          }
          parameters {
              booleanParam(
                  name: 'lazyBuild',
                  defaultValue: true,
                  description: 'Skip build'
              )
          }
          stages {
              stage('WTF') {
                  agent {
                      label 'master'
                  }
                  environment {
                      IS_LAZY = "${(params.lazyBuild) ? 't' : 'f'}"
                      IS_NOT_LAZY = "${(!params.lazyBuild) ? 't' : 'f'}"
                  }
      
                  steps {
                      sh 'echo IS_LAZY: $IS_LAZY'
                      sh 'echo IS_NOT_LAZY: $IS_NOT_LAZY'
                  }
              }
          }
      }
      

      Output:

      [00-build] Running shell script
      + echo IS_LAZY: t
      IS_LAZY: t
      [Pipeline] sh
      [00-build] Running shell script
      + echo IS_NOT_LAZY: t
      IS_NOT_LAZY: t
      

            abayer Andrew Bayer
            akdor1154 Jarrad Whitaker
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: