Adding Jenkins "Are you sure ..." Dialog

I have some Jenkins jobs that affect production servers. It would be nice to have "Are you sure you want to do this?" when the user starts one of these tasks. I did not find for this plugin. Has anyone out there tried to do this?

+4
source share
2 answers

You can add "Are you sure?" The parameter to build. When the user clicks "Build Now", they will be prompted to enter a parameter that can be selected "Yes / No" or a line. Then you can check this parameter using a shell or batch step and “exit 1” if it is not set to “Yes”.

+11
source

I applied this exact function on our Jenkins example. The way I did this is to use the "This function with parameters" parameter to add an assembly parameter that you can use to determine if commands should be executed.

On the job configuration page, select “This assembly is parameterized”, then “Add selection parameter” (you can also use any other type of parameter, just update the IF example below). Enter a name (no spaces or special characters), no and yes options (upper default - default) and optional description. Assembling screenshots of parameters


Now you can add the “Execute shell” build step, which checks the AreYouSure value to see if you want to complete the complete build. If the value is not yes, exit with code 1, so Jenkins reports a build error. All steps below the check will not be completed if the user does not select "yes".

Here is the code to check the value of a variable:

if [ "${AreYouSure}" = "yes" ] then ##commands to execute else exit 1 fi 

Shell script screenshot

+6
source

Source: https://habr.com/ru/post/1496228/


All Articles