0
pipeline {
    agent any

    parameters {
        booleanParam(name: 'RUN_Deploy', defaultValue: false)
    }
    
    stages {
        stage('Deploy') {
            when {
                allOf {
                    expression {
                        echo "Info - RUN_Deploy : ${params.RUN_Deploy}"
                        return params.RUN_Deploy
                    }
                }
            }
            steps {
                script {
                    echo 'Deploying the project'
                }
            }
        }
    }
}

The script above is my Jenkinsfile, when I push this script to github then set defaultValue to true and push to github again,
then Jenkins get notified to run the script, but it will print "Info - RUN_Deploy : false"
but when I type some dummy comment, then push to github then Jenkins get update and run script, it will print "Info - RUN_Deploy : true" successfully
I have no idea what's going on
And I can't find any information for my problem

akiyama
  • 43
  • 1
  • 5

1 Answers1

0

This is your entire code? I tested it on my Jenkins instance (version 2.420) and it works as expected.

The default parameter value is always false.

Please try my sample:

pipeline {
    agent any

parameters {
    booleanParam(name: 'RUN_Deploy', defaultValue: false)
}

stages {
    stage('Deploy') {
        when {
            expression {
                params.RUN_Deploy == true;
            }
        }
        
        steps {
            script {
                echo "Info - RUN_Deploy : ${params.RUN_Deploy}"
                echo 'Deploying the project'
            }
        }
    }
  }
}
MTLTR_
  • 3
  • 1
  • 6