My jenkinsfile has several paremeters, every time I make an update in the parameters (e.g. remove or add a new input) and commit the change to my SCM, I do not see the job input screen updated accordingly in jenkins, I have to run an execution, cancel it and then see my updated fields in
properties([ parameters([ string(name: 'a', defaultValue: 'aa', description: '*', ), string(name: 'b', description: '*', ), string(name: 'c', description: '*', ), ]) ])
any clues?
Log in to your GitHub account. Navigate to the forked repository. Once on the repository page, click on the Jenkinsfile . Next, on the resultant page click on the Edit button to edit your Jenkinsfile .
Configuration. Simply install the plugin, and then check the Post-Build action "Retry build after failure" on your project's configuration page. If the build fails, it will be rescheduled to run again after the time you specified. You can choose how many times to retry running the job.
One of the ugliest things I've done to get around this is create a Refresh
parameter which basically exits the pipeline right away. This way I can run the pipeline just to update the properties.
pipeline { agent any parameters { booleanParam(name: 'Refresh', defaultValue: false, description: 'Read Jenkinsfile and exit.') } stages { stage('Read Jenkinsfile') { when { expression { return parameters.Refresh == true } } steps { echo("Ended pipeline early.") } } stage('Run Jenkinsfile') { when { expression { return parameters.Refresh == false } } stage('Build') { // steps } stage('Test') { // steps } stage('Deploy') { // steps } } } }
There really must be a better way, but I'm yet to find it :(
Unfortunately the answer of TomDotTom was not working for me - I had the same issue and my jenkins required another stages unter 'Run Jenkinsfile' because of the following error:
Unknown stage section "stage". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.
Also I am using params instead of parameters as variable to check the condition (as described in Jenkins Syntax).
pipeline { agent any parameters { booleanParam(name: 'Refresh', defaultValue: false, description: 'Read Jenkinsfile and exit.') } stages { stage('Read Jenkinsfile') { when { expression { return params.Refresh == true } } steps { echo("stop") } } stage('Run Jenkinsfile') { when { expression { return params.Refresh == false } } stages { stage('Build') { steps { echo("build") } } stage('Test') { steps { echo("test") } } stage('Deploy') { steps { echo("deploy") } } } } } }
applied to Jenkins 2.233
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