In a declarative pipeline, I can specify the parameter that the pipeline expects right in the pipeline script like so:
pipeline { parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING' ) ]) }
is it possible do to in a scripted pipline? I know I can do this :
BUT, IS IT POSSIBLE TO DO THIS:
node{ parameters([ string(name: 'DEPLOY_ENV', defaultValue: 'TESTING' ) ]) }
Any Jenkins job or pipeline can be parameterized. All we have to do is check the box on the General settings tab that says This project is parameterized: Then we click the Add Parameter button. From here, we must specify several pieces of information:
15 First define your custom build parameter: pipeline { parameters { string( name: 'BuildConfiguration', defaultValue: 'Release', description: 'Configuration to build (Debug/Release/...)') It will automatically show up in page shown after you click "Build with parameters" from the Jenkins job page.
Jenkinsfile parameters are used to pass data to the build. There are three types of parameters we can pass - build, environment and pipeline variables
A build parameter allows us to pass data into our Jenkins jobs. Using build parameters, we can pass any data we want: git branch name, secret credentials, hostnames and ports, and so on. Any Jenkins job or pipeline can be parameterized. All we have to do is check the box on the General settings tab that says This project is parameterized:
I found a solution by experimentation so want to share it:
node { properties( [ parameters( [string(defaultValue: '/data', name: 'Directory'), string(defaultValue: 'Dev', name: 'DEPLOY_ENV')] ) ] ) .... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With