How to call a jenkins Job based on User inputs

10,084

Solution 1

There are a few plugins I have tried which collect user input on manually triggered jobs in a build pipeline: Active Choices Plug-in 1.2 and Extensible Choice Parameter 1.3.2.

With Active Choices you define a list of selections and a default value. With Extensible Choice Parameter you can have a text box and a default value.

This is how they work for me in Build Pipeline 1.4.8 on jenkins 1.628

  1. If you run the manual step directly in the pipeline the default is used and other parameters propagate through correctly.
  2. If you open the step there is an option to Build with Parameters which will ask for the user input. This works but other parameters like the build number do not propagate through so the pipeline is broken, and the pipeline screen does not show the status.

Solution 2

Jenkins will never pause and ask a user for inputs. It is an automated build system. It doesn't expect anyone sitting at the console watching the progress.

You can provide "inputs" or parameters when you manually trigger the job, i.e on the first job in your pipeline. You can them pass these parameters to downstream jobs, either through the Parameterized Trigger plugin or through a file copied between jobs.

If you need a human decision in the middle of your build flow, consider Promoted Builds plugin. With this plugin, a human can select a build, and then decide which "Promotion" to execute (which could branch your workflow as you need). The promotions can also be automated if needed, based on criteria and not human input.

Share:
10,084
Avadh
Author by

Avadh

Updated on June 13, 2022

Comments

  • Avadh
    Avadh almost 2 years

    The issue here is once the first Job in a Jenkins pipeline is done, we need to ask some inputs from user and based on the user Inputs to decide the next job to be triggered(Job2 or Job3) tried build flow and parameterzied trigger plugin but didn't find any suitable option under these. Any other plugin or jenkins feature which can help in achieving the above scenario?

  • Avadh
    Avadh over 9 years
    Thanks for your reply. So using this Promoted builds Plugin...Can I create a scenario where after the 1st Job is done....User is asked with a prompt like whether he wants to trigger Job 2 or Job 3 now?
  • Slav
    Slav over 9 years
    After the first job is done, it's done. You can send an email to relevant people informing them that it's done. After that, the relevant user will login to Jenkins, select Job 1's build, and choose which promotion (Job 2 or Job 3) to execute. There will never be "prompt" asking the user to do anything in the process, except for initial parameters during the manual trigger, or manually triggering a promotion.
  • Bruno P. Kinoshita
    Bruno P. Kinoshita over 8 years
    Hi Stephen. Interesting, I don't use the active choices with the build pipeline. If you can report an issue in issues.jenkins-ci.org, component=active-choices-plugin, detailing your use case, I can try to reproduce and see what it would take to support the build-pipeline plug-in as well :-)
  • stephen newman
    stephen newman over 8 years
    Hello, will do so tonight.
  • Bruno P. Kinoshita
    Bruno P. Kinoshita over 8 years
    Thanks Stephen! I'm half way through the PBS and R plug-ins issues. Next one will be Active Choices. Stay tuned :-)