Jenkins - Level2 - 2nd question (parameterized job)

Hello kodekloud.

Tried to pass this lab. Everything done in correct way, but test fails my job.

Why it so?

Got the error message:

  • job ‘parameterized-job’ is not built with env value ‘Staging’ or build failed

This is my pipeline code:


node {
    
    properties([
        parameters([
            string(name: 'Stage', defaultValue: 'Build', description: 'What stage?'),
            choice(name: 'env', choices: ['Development', 'Staging', 'Production'], description: 'What environment?')
            ])
    ])    
    
    stage('Echo parameters') {
        sh '''
            echo "\${Stage}"
            echo "\${env}"
        '''
    }
}

Follow the screenshots:

This is the correct way to do pipelines, so why is it fails? Do I need to do it in UI only?

It’s very weird way to write tests in such way IMHO.

Thank you.

Done it on UI (web interface), but anyway it is soooo weird to write tests in such way.

Thank you.