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

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

    XMLWordPrintable

Details

    Description

      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
      

      Attachments

        Issue Links

          Activity

            akdor1154 Jarrad Whitaker created issue -
            dnusbaum Devin Nusbaum made changes -
            Field Original Value New Value
            Labels pipeline
            dnusbaum Devin Nusbaum made changes -
            Component/s pipeline-model-definition-plugin [ 21706 ]
            Component/s pipeline [ 21692 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Assignee Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #290 (Web Link)" [ 21921 ]
            abayer Andrew Bayer made changes -
            Resolution Fixed [ 1 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

            People

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

              Dates

                Created:
                Updated:
                Resolved: