Jenkins: Set job timeout from a variable - jenkins

I want my Jenkins' job to use timeout value from the build variable.
Tried the following but ended up with Java runtime error.
Note: I am triggering my jobs using the rest api.

Related

Get value from parameterized remote trigger plugin

I tried to use parameterized remote trigger plugin to pass value to a remote job following https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/README_JobConfiguration.md guide. In the upstream job I input a=b into the Parameters field, but in the downstream job in a Execute Windows batch command step, when I tried to get the value using echo %a% the output is empty. How can I get the value of a from downstream job?
You need to make parameterized downstream job having a as parameter. I think you missed this point.

How to set schedule of a periodically built job by environment variables in Jenkins

In Jenkins you can set a job to build periodically using a cron-like time definition. e.g.
# switch timezone
TZ=Etc/GMT+6
# build once anywhere between 13:00 - 23:59
H H(13-23) * * *
Further you can configure parameterized jobs. That means on the go you can set the value of some predefined environment variables which will be used in the configuration. e.g. a certain branch on git you can let the user set the value of the environment variable "BRANCH" and than access this value using
${BRANCH}
in the configuration.
But this seems not to work with the Schedule value of a periodically build job configuration.
My problem:
I'm using the Job-Generator Plugin. It basically creates new (not parameterized but periodically running) jobs while using its own configuration as template.
In order to generate different jobs for different repositories you use the parameterized build as descriped before so in the generated job configuration the variable names ${...} are replaced by the value.
Now I don't want the Generator to run periodically but ofcourse only on demand. Therefor I want to replace the before mentioned cron rule by a variable so itself isn't build over night.
I tried to set CRON1 (TZ=Etc/GMT+6) and CRON2(H H(13-23) * * *) as unchngeable Generator variables and use
Schedule
${CRON1}
${CRON2}
but this makes Jenkins break and throw an error on trying to save the generator config.
line 1:1: unexpected char: '$'
How can I set the schedule value using an environment variable?
(I'm not trying to do Jenkins scheduled build Triggers with environment variable? . I'm using this but this doesn't solve my problem of the Job-Generator running periodically itself what it shouldn't)
You can't access the variables in that block, Instead you can use plugins to schedule the jobs. parameterized-scheduler-plugin this plugin can be helpful to you in your case. It does have good integration with pipeline scripting also. Hope this helps.

JMeter & Jenkins - passing jmeter parameters to downstream build

The Setup - A jenkins job using jenkins parameters testApp and testEnv. The Execution Batch looks like this:
C:\jmeter\apache-jmeter-3.2\bin\jmeter.bat -n -t
C:\JMeter\Scripts\API_scripts\%testApp%.jmx -Jtestenv=%testEnv% -JtestApp=%testApp% -JtestBrowser=NA -l
C:\AUTO_Results\jtl\%testApp%_%testEnv%.jtl
Post-build Actions
Console output (build lob) parsing with a global rule so that the Failures that are logged in the Jenkins Console window will consider the JMeter script failing. (discussed Jenkins shows JMeter script failure even though the script actually passed)
Triggered parameterized build - this is a separate jmeter script that updates a wiki page with either PASS/FAIL and uploads the JMeter report.
The Issue - How do I get the downstream Triggered build to use the parameters from the upstream script? I set the Parameter = Current build parameters but it's not applying those. Also, I wont know the value of the testResult parameter until the upstream build finishes. I tried adding %testResult%=PASS to the 'Predefined parameters' box
As per Parameterized Trigger Plugin page:
The parameters section can contain a combination of one or more of the following:
a set of predefined properties
properties from a properties file read from the workspace of the triggering build
the parameters of the current build
Subversion revision: makes sure the triggered projects are built with the same revision(s) of the triggering build. You still have to make sure those projects are actually configured to checkout the right Subversion URLs.
Restrict matrix execution to a subset: allows you to specify the same combination filter expression as you use in the matrix project configuration and further restricts the subset of the downstream matrix builds to be run.
So you basically need to copy over the parameters you would like to have in the "downstream" job from the current one.
As a workaround to current performance plugin limitations you can consider running JMeter using Taurus tool as a wrapper, it has flexible and powerful pass/fail criteria subsystem which will basically return to Jenkins non-zero exit code triggering build failure in case of issue in the test. If everything goes well Taurus exit code will be 0 which is considered successful by Jenkins. Check out How to Run Taurus with the Jenkins Performance Plugin article for more details.

Jenkins build trigger

I used jenkins remote trigger build option at job A and triggered another job B. When I open job B build, I could see "Started by remote project <path to job A>". I am trying to get the value from job B after execution but I not working. I tried working with BuildUser plugin which gave null output. Could someone help me to find a way to find the information?
The Parameterized Remote Trigger Plugin job setup options have a section Build Info with a field Parameters. Define parameters there like:
TRIGGERED_BY_JOB=${JOB_NAME}
TRIGGERED_BY_BUILD_NO=${BUILD_NUMBER}
and use them accordingly in your job B.
See Jenkins Set Environment Variables for other available information.

Pipeline - Parameterised Trigger Plugin

I have a pipeline type job in my Jenkins. What I am trying to do is to run some pipelines with a parameter like release. For example, I want to run this pipeline for version 1.3.5. I prepared a pipeline code for that and tried to use Parameterized Trigger Plugin to make it parameterised. This plugin was working for normal type tasks but, I couldn't make it works with pipelines.
Here is my definition of the variable;
I can't access the variable I defined with the plugin. Here is the pipeline part which tries to access it;
....
build_tag = "${TAG}"
But, build_tag variable is always null. I tried env.${TAG} and ${env.TAG} but no result.
I defined String param named THIS_IS_TEST and was able to get the value with -
echo "${THIS_IS_TEST}"
Make sure that the plugin is updated

Resources