Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: how to make parameters required in a parameterized build?

In Jenkins is there a plugin for parameterized builds to make the parameters required? The fields under the standard "This build is parameterized" option do not seem to provide that.

Clarification: by "required" I mean that the build will not execute until the field is populated with a value. This would obviously preclude automated triggers.

like image 672
Ryan Nelson Avatar asked May 24 '12 17:05

Ryan Nelson


People also ask

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

How can we get a parameter value in parameterized job when running on Windows?

The parameter is available as environment parameters. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env. FOO} ) can access these values. This is not exactly a return value, but you can pass any parameter (with its value) to the downstream job with Parameterized Trigger Plugin.


2 Answers

The accepted answer is no longer valid.

There was a plugin that did that but is no longer maintained.

There's an open bug to support it.

In the mean time what you can do is check if your parameter is present and if not throw an error like:

if (params.SomeParam == null) {     error("Build failed because of this and that..") } 
like image 88
hakamairi Avatar answered Sep 25 '22 00:09

hakamairi


This is the plugin i use to do this type of stuff: link...
You can set a regular expression to validate the input against

like image 41
Tyler Smith Avatar answered Sep 26 '22 00:09

Tyler Smith