Is it possible to get changes of the parameterized pipeline on the fly after making changes there?

For example I have a pipeline code:

                string(name: 'TARGET_HOST', defaultValue: 'test', description: 'Host on which artifact will be deployed'),
                string(name: 'ARTIFACT_ID', defaultValue: 'test', description: 'Name of artifact which will be doployed'),
                string(name: 'ARTIFACT_VERSION', defaultValue: '1', description: 'Version of artifact which will be deployed')

And I decided to change defaultValue for TARGET_HOST parameter from test to 1.

After such changes, I'll need to run job in order it apply changes and only running it for the second time after making changes, I'll obtain applied changes.

Is there a way to make job pick up changes during first run after making them?

So far I found a way to do it with Input structure:

def values = input id: 'Run-test-suites',
        message: 'Workflow Configuration',
        ok: 'Run',
        parameters: [
                        $class      : 'BooleanParameterDefinition',
                        defaultValue: true,
                        name        : 'checkboxVal',
                        description : 'Testing of checkbox param'
                        $class      : 'StringParameterDefinition',
                        defaultValue: "test",
                        name        : 'stringVal',
                        description : 'Testing of string param'
                        $class     : 'ChoiceParameterDefinition', choices: '1\n2\n3',
                        name       : 'choiceVal',
                        description: 'Testing of choice parameter'

But I want to have something more flexible.


Currently what you are asking for is not possible. This is due to the way that the Jenkinsfile is loaded into the pipeline.

I think dolphy said it best on this StackOverflow answer (I saved this link a while ago to follow it for changes, because I had the same questions):

Jenkins does not know about the new parameters until it retrieves, parses, and runs the Jenkinsfile, and the only way to do that is to...run a build.

In effect, the build history will always be "one run behind" the Jenkinsfile; when you change something in the Jenkinsfile, the next build will run with the "old" Jenkinsfile, but pick up and process the new Jenkinsfile for the build after that.

There is also a related Jenkins Ticket you can follow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.