0

I have this jenkins stage:

    stage('Run tests?') {
        agent none
        steps {
          script {
            TESTS = input message: 'User input required', parameters: [
              choice(name: 'Run Tests', choices: 'yes\nno', description: 'Run unit and e2e tests?')]
          }
        }
    }

and below I do this:

  stage('test-unit') {
            when {
                expression {
                    return shouldRunTests('yes')
                }
            }

however, I'm wondering how to pass the user input of either yes or no into the function? so far, it's always running the tests regardless of whether I say yes or no. I know above I have hardcoded ('yes') that's because I saw an example do it like that. anyone care to help me how I can pass this in?

my shouldRunTests function just returns true or false based on the parameter passed in

the venom
  • 661
  • 3
  • 9
  • 17

1 Answers1

0

You can create "TESTS" variable before the pipeline block starts and use it in any stage, as done in this example.

Lesly Bernaola
  • 393
  • 1
  • 12