I want to add a conditional parameter to jenkins job. In other words, I want to add a boolean parameter when checked, another string parameter appears to the user when they build the job. If not checked the string parameter should not appear as a parameter when the user builds the job (Kind of a similar behaviour to the conditional steps of jenkins but on parameters.). Is their a plugin for that?
In the image below, if repo_update is not checked: Clean and Changesets should not be present to the user if they are building the job.
You might want to look at the Multi job plugin
Make the parent and child two separate jobs. This to me makes more sense logically.
In the build part, run the parent job first.
Based on a condition, the child job can run.
You can add the child params in the child job only, so people who configure the parent job will never see the child params
This to me feels like a cleaner implementation.
Related
How could I check passed job parameters before the job start building.
Based on the result of applied conditions for passed parameters, if result is True, I will start the build, if result is False, then skip the job without even start the build and then abort it or make it as Failure/Unstable.
Note, I know I can do that inside the job itself in Jenkinsfile, by check the passed parameters there. But I would like to do that in way so that I don't need to start build job directly.
I think what I'm looking for is such as Pre-Build procedure.
If Pre-Build == True:
-> Start Build Else
-> Skip the build at all
Is there a plugin or a workaround can help in that please ?
Thanks.
Nope. Parameters are part of a job. A ā€¯valid paramter" parameter can only be determined in the context of a job. The only thing that would know what is a valid is the logic inside the job. Therefore bthe job must be triggered to do the evaluation.
You could create a generic trigger job which took your parameters, did some universal validation and the triggered the actual job, passing validated parameters in.
But what would you achieve by that? There are many extended build parameters plugins (including choice parameter) which only let the user pick from available options.
I have a parent jenkins multijob that calls 3 children jobs, passing to the children the same parameters the parent was built with.
Each child needs to use the same timestamp as it is a unique identifier that each child needs to search for on a webpage.
My problem is this:
When the parent is built, the "name" parameter is set to ${BUILD_TIMESTAMP}, lets call this "02201200" short for Feb 20, 12:00. Each child is called with "pass current job parameters". However, instead of each child receiving 02201200, they each receive ${BUILD_TIMESTAMP} and fetch this value again (eg 02201204).
How do I force the parent to evaluate ${BUILD_TIMESTAMP} and pass its evaluation to the children instead of the variable itself?
One possible solution would be to write the value of this time stamp to a file. Then you could reference that value in subsequent jobs via the "Parameters from properties file" option. Obviously you would just keep overwriting this file every time your job sequence runs.
I used this method and also ended up generally saving all metadata (system/environment variables, jenkins parameters, and build properties, etc) into a properties file and even archived them. This approach simplifies/works around many problems I had. Now, every build has its metadata archived, for downstream jobs or later references, I can get all necessary information from this one file; no extra parameters need to be passed around.
Furthermore, if anything goes wrong, the metadata is very helpful for investigating. I would recommend this simple strategy as it has proven extremely useful to myself and my team.
I have Upstream Job(MultiJob) which takes a String Parameter called freshORrerun, to take string value as "fresh" or "rerun" string value, which i need to pass on to downstream(standalone build) jobs to check the value is "fresh" or "rerun". Based on which, in child jobs's i will trigger complete tests run (pybot) or rerun (rebot) of failed tests.
here i have attached the screenshots how i have configured. When i print the passed string in child job it is empty.
Overall Job configuration.
Multi Job phase config and child Jobs
I have many no.of robot tests running them takes a lot of time. i need a way to run only failures of previous run, so that it gives me quick picture of how many got fixed. Could Some one please help me with this.
Click the 'Add parameters' button, select 'predefined parameters' and add: freshORrerun=${freshORrerun} to the list.
You can do it using one plugin called parameterized job trigger in which you will get options to pass parent job parameters to child job.
Note:- For this, you have to create parameters in child job also. These parameters will be overwritted.
plugin link
I want to pass $CHANGES from my upstream project to downstream project.
I looked at How to pass ${CHANGES} to downstream job? which did not work for me. The All Changes Plugin does not put the changes in environment variable so I can't access them in the downstream job (or maybe I don't know the correct env. variable it uses)
The method to get changes from Parent Job URL and parse the XML also does not work, because it would be hard to correlate the parent job number which triggered this downstream build.
Is there something else that I can try?
The Parameterized Trigger plugin allows you to pass variables to downstream job.
Click "Add Parameters" dropdown under "Trigger parameterized build"
Select "Predefined Parameter"
Type CHANGES=${CHANGES}
The left side of = is the variable that will be injected into the child job.
The right side of = is the value from the current build.
Provided that you have ${CHANGES} as an environment variable in the current build, it will pass the same into the child build. You can change the left-side variable name to avoid any conflicts.
Note: Since version 2.23 of the plugin, the left side variable has to exist as a parameter in the child job. You need to define an empty "Text" parameter called CHANGES (or whatever your left side name is) in the child job configuration.
Need some help regarding jenkins job view;
I need to have one Jenkins view which matches two conditions
Specific Job name (ex: all the jobs which has trunk as one of the string in job name)
and Job Status;
Basically i need to list all the jobs which has job name containing trunk and which is failed under one view.
I know there is sectioned view and list view where we can list the jobs based any one of the condition above but i need to match both the condition.. is there a way to do this using any of the Jenkins Plugins?
Appreciate your help in this regard.
Regrds,
Raju.
You can use the View Job Filters plugin for this - it lets you build views which chain together filters to create the custom views, and the filter options include:
Job name, including regular expression filters (i.e. you could filter by ^.*trunk.*$)
Job status
I think that should allow you to build the list view you need. The image below shows an example taken from the build system I manage, where we were able to create a view with the same characteristics as you require (naturally exchange labos for trunk).