6

I have a Jenkins job that takes environment name as a parameter. On another site/dashboard, I would like to create links to this Jenkins job. But the link should pre-populate the parameter based on where it was clicked from.

Something like this,

<a href="https://jenkins/<someJenkinsAPI>?ENV=env1">env1</a>
<a href="https://jenkins/<someJenkinsAPI>?ENV=env2">env2</a>

Is this possible?

Nikhil Owalekar
  • 649
  • 1
  • 11
  • 18
  • Do you not have the option to select a parameter of type "Choice"? The first value in the predefined list is the "default" if the build is just run. There are several "Extended Chicory plugins which give you greater flexibilty. Search plugins.Jenkins.up for choice or parameters – Ian W Jun 19 '19 at 10:11
  • @IanW Yes, I'm already using the choice parameter. I just wanted a specific choice pre-selected from the dropdown upon visiting a certain URL – Nikhil Owalekar Jun 21 '19 at 05:09
  • Does this answer your question? [How to pass default values to a Jenkins build using the Parameterized Build Plugin?](https://stackoverflow.com/questions/24024936/how-to-pass-default-values-to-a-jenkins-build-using-the-parameterized-build-plug) – Kim Kern Jul 15 '20 at 10:43

1 Answers1

9

Just came across this plugin: https://plugins.jenkins.io/build-with-parameters With this, you just need to go to a URL like this: https://jenkins.mycompany.com/job/nikhil-test/parambuild/?ENV=env2&APP=myapp

This will open up the /buildWithParameters page for that job, with the values from your URL pre-populated on the page! If you don't provide a parameter OR provide an invalid value for the parameter, it will pre-populate that parameter with the default value.

build page

Nikhil Owalekar
  • 649
  • 1
  • 11
  • 18
  • Thank you for this. But, say I have a buildA which pushes a version of a library to some artifactory, say I create a new buildB, how do I create a choice(or a dropdown) in buildB to prepopulate all the versions including the latest one for the library to be used in buildB? – ApJo Jul 11 '23 at 20:05