Jenkins Load Webpage as Parameter Input
The basic parameter of the Jenkins job has limited functionality, it doesn't support,
- Interact with other parameters
- Load dynamic data from web API
A great plugin Active Choices provides the above-missed functionalities. However, the performance becomes worse when the number of parameters is too many or the parameter cascade level is too deep. For example, changing a parameter takes a long time to re-render the UI.
Is there a better way to render more complex input parameters for a job?
The answer is yes. The Active Choices plugin supports loading a webpage and rendering it in the Jenkins job build with a parameter page, with modern frontend technology, we can use a web framework such as Angular or VUE to develop a better UI to allow users to input the parameters.
Here are the steps,
- prepare a website, and deploy it to a server. For example https://internal.local/jenkins/job1
- configure the resource root URL for Jenkins under
Manage Jenkins ยป System
in the section Serve resource files from another domain. Inputhttps://internal.local/jenkins/job1
as the resource root URL - create a Active Choices Reactive Reference Parameter for the Jenkins job
-
in the parameter script, input
-
in the choice type, select Formatted HTML
- approve the script and click build with parameter, you'll see the rendered html webpage.
Next, I'll introduce how to,
- Get the Jenkins authenticated state
- Hide the Jenkins Job's Build and Cancel button
- Launch the build in the webpage