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
Asked
Active
Viewed 1.2k times
10

Furkan Yavuz
- 1,858
- 5
- 30
- 51

Alex Brodov
- 3,365
- 18
- 43
- 66
-
did you figured out how to validates fields and not start the build if something wrong? – user2988257 Dec 14 '16 at 14:21
-
No... Any idea without changing the core source of Jenkins – Alex Brodov Dec 14 '16 at 14:26
-
1Don't forget a Jenkins jobs can be run from CLI or REST api, so hidden the button is not a real solution. Failling the job when input isn't correct is a better option. – Cédric Levasseur Jun 29 '17 at 13:27
2 Answers
3
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.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
0
At the moment, the validating string parameter is the closest you'll get.

Andrew Gray
- 3,593
- 3
- 35
- 62
-
I like the 'at the moment'. It's still the case in 2021. Jenkins is a joke, the parameters limit you so much, it's crazy. – Garbem Mar 11 '21 at 11:34
-