Skip to content

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,

  1. prepare a website, and deploy it to a server. For example https://internal.local/jenkins/job1
  2. configure the resource root URL for Jenkins under Manage Jenkins ยป System in the section Serve resource files from another domain. Input https://internal.local/jenkins/job1 as the resource root URL
  3. create a Active Choices Reactive Reference Parameter for the Jenkins job
  4. in the parameter script, input

    Java
    return """
    <iframe id="job1" src="https://internal.local/jenkins/job1"
      style="width:100%;height:800px;border:none;" scrolling="no"></iframe>
    """
    
  5. in the choice type, select Formatted HTML

  6. 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