How to pass default values to a Jenkins build using the Parameterized Build Plugin?
-
21-12-2019 - |
سؤال
I'm using the Parameterized Build Plugin in Jenkins. I want to provide a link to the build page, but configure the default value for one of the fields that shows up in the form. This value is going to be different every time the job is run, but I want it to be configurable from some other page. Essentially I want to do something like click on a link that looks something like this:
https://jenkins/job/Sandbox/build?delay=0sec&Test=foo
And see this on the build screen:
So then I can fill out the rest of the values (or even modify the default value) and then click Build. Is this possible?
المحلول
Yes, it's absolutely doable - there is a plugin for that:
Just install it and change the url to actually use the plugin:
https://jenkins/job/Sandbox/parambuild?Test=foo
And that's should do it...
نصائح أخرى
You don't need any additional plugins for this. This comes natively with Jenkins
https://jenkins/job/Sandbox/buildWithParameters?delay=0sec&Test=foo
The above will trigger the build job immediately (or whatever the delay may be). This is suitable for automation.
The Build With Parameters Plugin is similar, but it will open a Jenkins confirmation page with pre-populated parameters (from the URL), and prompt the user to click the Build button. It is not suitable to automation.
You can work with build triggers /build?token=TOKEN_NAME or /buildWithParameters?token=TOKEN_NAME&Test=foo&AnotherTest=(your value)