In Jenkins parameterized project, is there a way to receive the variable in different name?
for e.g:
JOB_A:
sends parameter FOO='myfoo' when it calls JOB_B
JOB_B:
Is there a way to receive it on different name, say 'BAR', so it will be BAR='myfoo', I know this can be done with BAR=$FOO in Build/Execute shell, I am here to find if there is any option to do this in General/This project is parameterized section.
On JOB_A, in 'Trigger/call builds on other progects' find 'Predefined Parameters' from 'Add Parameters' drop-down. You just want to put this:
BAR=${FOO}
Click to see the screenshot
Related
I have a Jenkins job that takes environment name as a parameter. On another site/dashboard, I would like to create links to this Jenkins job. But the link should pre-populate the parameter based on where it was clicked from.
Something like this,
env1
env2
Is this possible?
Just came across this plugin: https://plugins.jenkins.io/build-with-parameters
With this, you just need to go to a URL like this: https://jenkins.mycompany.com/job/nikhil-test/parambuild/?ENV=env2&APP=myapp
This will open up the /buildWithParameters page for that job, with the values from your URL pre-populated on the page! If you don't provide a parameter OR provide an invalid value for the parameter, it will pre-populate that parameter with the default value.
I have a requirement in Jenkins as below.
1) Select environment in choice parameter i.e. prod/staging/sit
2) Based on the above environment value, I need to run execute .SH file to fetch the list of deployed applications from my runtime.
3) Populate the retrieved data again in to a choice parameter and allow user to submit for any start/stop action.
Is it possible in Jenkins to trigger an action based on user selected value in choice parameter? something like AJAX....
it is possible in Jenkins to do a choice active based choices.
you need to add a parameter named "Active Choices Reactive Parameter"
in this parameter there is a field named "Referenced Parameter",
whenever this value is changed the Parameter get's reevaluated based on the changed value
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
I've just started working with Jenkins plugin development and have some questions:
How to create a custom Jenkins "New item" type which should have some predefined build parameters ?
Could you please provide a tutorial or an example how to do such things.
I am thinking of the following solutions:
- develop a custom job type which will have build parameters predefined inside it
- develop a parametrized job custom build parameter type which will get more than one value during the build setep
I have tried to create parametrized job custom build type for my plugin but in my case I need to define more than one build parameter which as I see is not possible because Jenkins's buildWithParameters function gets only one value from my type regarding of this:
https://gitorious.org/jenkinsci/jenkins/source/bbdf5c21153c7e9d60d6ed158d32aa8852f00501:core/src/main/java/hudson/model/ParametersDefinitionProperty.java
Thanks,
Mane H
I have Job on Jenkins ver. 1.500 with build ID parameterized.
I want to use this parameterized value in the subject line of section "Post-build Actions".
If I try to access using $ID or ${ID} its printing it as plane string "$ID"[without value substitution]. I am aware of environmental variable $BUILD_NUMBER, which is giving the current job #number.
Can someone share, how to achieve this simple task of reading build number?
$PROJECT_NAME - Job # $ID built at $BUILD_ID - $BUILD_STATUS!
--Thanks,Prashant
It sounds like you are talking about Editable Email Notification post-build action. It has it's own way of referencing variables.
Variables that are available within the plugin, can be referenced directly as ${VARIABLE}, in both the body of the email and the subject line. For a list of available variables, click on the ? icon for on-page help.
However to access other environmental variables, including the parameters used by the build, you have to use the format ${ENV, var="VARIABLE"}, so in your case, it would be ${ENV, var="ID"}