I'm trying to find jenkins parameter plugins to do;
Editible textbox (multiline)
Set default text from property file (something like groovy script)
Can you please suggest any plugins?
I tried Active chioce parameter plugin, Extended choice parameter plugin. But those are only provide choice option not textarea.
And Dynamic parameter plugin also seems not support multi-line.
Exists a way in jenkis jobs configuration to pass text parameter to execute a job. Adding Text Parameter, you can define a simple text multiline parameter, where users can enter a text value, which you can use during a build, either as an environment variable, or through variable substitution in some other parts of the configuration.
To define parameters for your job select "This build is parameterized", then using the drop-down button to add as many text parameters or other type as you need.
more info look at
Parameterized Build
Related
I am trying to use active choice reactive reactive reference parameters in Jenkins Freestyle Job where I want to read a file and show some of its content as value of this reactive reference parameter, and also to be able to edit the input.
Can this be achieved?
The configuration looks like this as of now :
The output I am expecting is something like this:
This is the input textbox where "ABS= DEF= " is output from fileconfig param, and also this input is not hidden and can be edited if need be, and then should be passed to Jenkins build as parameter.
Note: I used : return "<input name="value" type="text">" in groovy script which is also not working for me.
I am trying to create a Jenkins job that has dependent parameters.
Firstly I want to be able to choose a main parameter:
And then secondly to be able to choose from a set of options that are dependent parameters of the main parameter.
If I select a different main parameter:
I then want to have a different set of options as the dependencies to the second main parameter.
Please, can you help me with how I can achieve this?
I would suggest the Active Choices plugin (also known as "uno-choice"). (This question has references to both, though they're not the accepted answer.)
For your specific use case, you'll want to add two parameters to your job:
Active Choices Parameter
Name: MainOption
Script: Groovy Script
return ['A','B']
Active Choices Reactive Parameter
Name: DependentOption
Script: Groovy Script
def choices
switch(MainOption){
case 'A':
choices = ['Blue','Green','Yellow']
break
case 'B':
choices = ['Black','White','Grey']
break
default:
choices = ['N/A']
break
}
return choices
Fallback Script: Groovy Script
return ['Option error']
Referenced parameters:
MainOption
The "Referenced parameters" setting is the key - when that value is changed, the plugin will re-evaluate the Groovy script, giving you the dependent parameter effect.
For all of you who stumble upon the same kind of problem (like I did). There is a fairly new Jenkins plugin available that does exactly what is desired here: display a dependent set of drop-downs, updating dependent boxes when a main box changes selection.
For your job you just need to follow the following steps:
Install "Multiselect Parameter Plugin"
The "multiselect parameter plugin" can be installed from Jenkins plugin management, the documentation is available on its Jenkins Plugin page.
Add new parameter
Use "Multiselect Parameter" type
Set name to a sensible value
give a short description
configure like shown below:
H,Main option,Dependent option
V,SELECTED_MAIN,SELECTED_DEPENDENT
C,A,Blue
C,A,Green
C,A,Yellow
C,B,Black
C,B,White
C,B,Grey
Use selected values
When you run "build with parameters" in your job, the following boxes are displayed for selection:
In your build script you can simply use the configured environment variables SELECTED_MAIN and SELECTED_DEPENDENT, which contain the selected values from both select boxes.
I am using parameterized build in Jenkins? Is there a way when changing the values of parameters (String parameters for example) to save them for next build instead of using the default?
You can use Extended choise parameter plugin and set default value source to file as described in another question.
I'm using jenkins to build an ant project.
The target names in the build.xml are too verbose.
How can I give the target a more user-friendly name?
For example:
I want to change server_remote_stop to "Stop Server", and server_remote_start to "Start Server" without modifying the target names in build.xml (because this build.xml is used by other programs).
Is this possible?
Yes, it is possible, but you will need to use a different Active Choices parameter type: Reactive Reference Parameter.
Here are the settings that I used:
One active choices parameter named PARAMETER1 with some random server names (AAA, BBB)
One active choices reactive reference parameter, that is watching PARAMETER1, has Choice type as "Formatted HTML", has the Advanced option "Omit value" checked, and the following script:
html ="""
Start Server $PARAMETER1
Stop Server $PARAMETER1
"""
This kind of Formatted HTML is rendered in the UI as HTML, and you can mimic HTML components used in Jenkins, like a select box (you can use a radio, checkbox, etc). What is important is that you return some element whose name is "value" and omit the value field that is automatically created by the plugin (thus the advanced option Omit Value).
Since it is a reactive parameter, you can reference other parameters in your Groovy script as well :-)
Hope that helps,
Bruno
I have a Jenkins parameterized build. I tick the "this build is parameterized" and I set a "Choice" environment name to be "ENVIRONMENT" and then as choices I define human readable names such as "Test env1", "Test env2", etc. However I want these keys to actually contain different values, for example "Test env1" key would container a file path as its value. How can this be done?
I have managed to get the keys/values with a dropdown select parameter working with the Active Choices Plugin, the answer was actually buried in the comments on the plugin page itself.
You simply need to use a map rather than a list when writing your groovy script to define the dropdown options. The map key is what the parameter will be set to if the user selects this option. The map value is what will be actually displayed to the user (i.e something human readable) in the dropdown list.
Here are the steps.
Ensure you have the Active Choices Plugin installed.
Open the configuration of your Jenkins job, select This project is parameterised.
Click Add Parameter and select Active Choices Parameter.
Name your parameter ENVIRONMENT and click the Groovy Script check box.
In Groovy Script enter content: return ['env1 file path value':'Test env1', 'env2 file path value':'Test env2'] For this example the user will see a dropdown with 2 options: Test env1 and Test env2. The keys: env1 file path value and env2 file path value are what the Jenkins build parameter will be set to if the option is selected. Modify these as necessary.
In this case ENVIRONMENT is the key and "Test env1", "Test env2", etc. are the possible values. Choice parameter is to restrict the possible inputs.
Based on the value of %ENVIRONMENT% you can execute multiple pathways in your batch scripts or whichever scripts you are executing