Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I validate Jenkins build parameters on the front-end to enable/disable the build button?

I have complex jobs with a lot of parameters, is there any way to validate those parameters using JavaScript form validation or with some other methods, and if the user's input isn't not correct, i'll show an error message and also disable the build button. I've tried installing the Validating String Parameter Plugin , it seems like that it's only displaying errors

like image 805
Alex Brodov Avatar asked Jul 18 '16 17:07

Alex Brodov


People also ask

How do I enable build with parameters in Jenkins?

Any Jenkins job or pipeline can be parameterized. All we need to do is check the box on the General settings tab, “This project is parameterized”: Then we click the Add Parameter button.

How do I change the build parameters in Jenkins?

To execute the Jenkins job from Jenkins web interface first go to respective project workspace and then click on “Build with Parameters” option from left panel. After that, you will be asked to choose/set parameter value (In my project I have set BROWSER parameter.)

Which of the following is the best practice to follow while administering and maintaining Jenkins?

Of all Jenkins best practices, it's best to use Thin Plugin in conjunction with either creating a pipeline by configuring a job. Else, if you have your server deployed over cloud point 'E' (above) is the recommended approach.


1 Answers

You can combine:

  • the JENKINS Validating String Parameter Plugin
  • a script able to validate values (independently of the plugin)
  • a condition build step (with the JENKINS Conditional BuildStep Plugin/ JENKINS Run Condition Plugin)

That way:

  • the validating String parameter plugins prevents users to enter invalid values
  • the script (written in any language you want) will validate those parameters again, but this time called as a "Script Condition", to decide if a step should be executed or failed.

That ensures that, even if the job is called directly through API (without any string validation from the first plugin), the script (called by the second conditional step plugin) will block/fail the job if its execution (validating the strings/parameters by script) does end with a failure status.

like image 184
VonC Avatar answered Sep 19 '22 14:09

VonC