misco
misco

Reputation: 1952

How to run parametrized build after commit to repository?

I have parametrized build job in Jenkins. It has configured SCM polling and the build job is started after new commit.

Parameters for this build job are location profiles defined in main pom.xml. Count of these profiles is static and persistent. So after every commit I need to build a project for the same profiles. One profile is started for one build.

It is able for manual triggering when I write profile name and start the build job. But after new commit this build job is started without parameters. So is there any way how to define list of parameters for build job - one parameter per one build.

Upvotes: 1

Views: 4570

Answers (2)

Slav
Slav

Reputation: 27505

An SCM change will trigger a related Jenkins job. Once. That's it.

When that job is triggered, and is configured with parameters, it does have default parameters.

For string parameters, it's the default value entered in configuration page (if you haven't entered one, the default is just that: none).

For single choice-style parameters, it's the top-most value.

For multi choice-style parameters, again, unless a default is provided in configuration, it's nothing.

If what you want is to trigger multiple runs of the same build for the same SCM change, then you've configured your jobs wrong.

  1. Either create a matrix job, and configure an axis for every "profile" as you call it.
  2. Or create multiple jobs, and chain them, so that first is triggered by SCM change, and the rest are triggered in sequence

Upvotes: 1

Technext
Technext

Reputation: 8117

If you only want to specify one default string that should be picked up while building using Poll SCM feature, then you should try using the following method:

Select the following options in Extended Choice Parameter:

  1. In Simple Parameter Types section, go for Single Select in Parameter Type

  2. Instead of Choose Source for Value, go for Choose Source for Default Value. Now enable the radio-button named Default Value. Enter whatever string you want to specify. Build will pick-up the given string as the default one.

enter image description here

Hopefully, it should work. At least, it works when i use Build periodically option. :)

Upvotes: 0

Related Questions