Defining paramertes in a pipeline

Pipeline
Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines into Jenkins.

The Parameters Directive
If parameters are defined in Jenkinsfile, defaults can be set there using the defaultValue: '...' syntax. Those defaults will reflect in the UI after a build cycle, as described in the Parameter Definition Update Cycle section.

"Build with Parameters" gives the user the option to specify values for each defined parameter, before initiating a build. If the user chooses not to change anything, the build will start with parameters carrying their "Default Value". A new value specified in the UI will override the default specified in Jenkinsfile. If the build is started automatically, the "Default Value" is used, unless the build triggering function provides the corresponding values, as follows

pipeline {
    agent any
    stages {
        stage("Setup Parameter") {
            steps {
                script {
                    properties([
                        parameters([
                            string(
                                name: "STRING",
                                defaultValue: "training"
                                )
                            ])
                        ])
                    }            
                }
            }
        stage("Print Parameter") {
            steps {
                echo "string parameter is ${STRING}"
            }
        }
    }
}

Recent Comments

No comments

Leave a Comment