is it possible to check in Jenkins pipeline script which executor is executing the job.
Suppose there are two executors (Executor-1 and Executor-2) and JOB-A is triggered. As the Executor-1 is free, execution of JOB-A is started by Executor-1.
I would like to find out in my pipeline script of JOB-A that the execution is currently running on Executor-1.
Is there a way to find this?
I found the answer by going through this issue.
The environment variable EXECUTOR_NUMBER can be used to find on which executor is the job running.
Related
We using open source Jenkins 2.107.2 on AWS.
We use Jenkins pipeline for all our apps.
We do not use multi-branch pipelines.
For one of the application, Jenkins job was failing due to the post-deploy test cases failures. Because of that the job is continuously executing the job until it succeeds.Can we configure Jenkins to retry failed builds only 1/2 times.
I saw https://wiki.jenkins.io/display/JENKINS/Naginator+Plugin
but this plugin is not supported for pipeline.
Is this what you need?
stage('build') {
if(!isBuildable){
//stop build and jump to next stage
return;
}
//do build tasks
}
isBuildable variable could be the result of other stages or any value that indicates that it should be built or not.
Thanks for looking into my concern.
I have 3 jenkins jobs. JOb A, B & C.
Job A starts at 10PM at night.
JOB B is a down stream of Job A and runs only if job A is success.
Job C is a downstream job of job B
Now I want job C to be triggered after successful completion of job B or at at a scheduled time. Problem is if I schedule job C as down stream as well as with a schedule. It runs twice.
But, it should run only once.
Please help me to achieve this.
Did you try "Conditional BuildStep" plug-in? You can execute a downstream job (or a script) based on "Build cause"
You can add more than 1 "single" conditions for each build cause.
Now you'll need to decide when to run a job, as a timer or as a downstream
You can use jenkins pipeline plugin. You can create a pipeline job with stages. A pipeline will proceed only to next stage if previous stage is successful. Refer documentation for more details on pipeline.
Pipeline comes with a lot of flexibilities in which you can define the flow. You can either use a declarative pipeline or a scripted pipeline. Good number of examples can be found in here
I'm trying to test out the parallel functionality for a Jenkins pipeline job, but for some reason the individual build steps of the parallel job never get passed off to an executor and processed. Normal single-threaded pipeline jobs have no issue processing. I tried restarting the Jenkins server in case some resources were locked up, but it did not help.
The full script I'm trying to execute is:
def branches = [:]
branches["setup"] = {node("nsetup") {
echo "hello world"
}}
parallel branches
I have only one node, the master, and it has 5 available executors. It is configured to "use as often as possible". I'm pretty new to Jenkins and setting up a server for the first time, so maybe there's something I missed in the configuration that isn't related to the job.
Does anybody have any suggestions?
And 2 minutes after I post I figure it out! Every time.
Turns out I just didn't have any idea how the "node" command really works. By specifying a parameter in the parentheses, it was preventing it from releasing to an executor. I'm guessing that must tell it to try executing on a certain node matched by label, and I was using it like it was some random logging field. Oops!
For running all jobs on Jenkins I use groovy script. I have one disabled job in list and it should be skipped. How to realize it using java/groovy?
Currently running of all jobs stops after skipped job.
You can use the Jenkins API to determine whether the job is disabled/enabled. For example,
if(Jenkins.instance.getItem("MyDisabledProject").disabled) {
echo "Job is disabled!"
}
i have 2 pipelines in jenkins and i need to run a final job if last 2 jobs in 2 pipelines are successfull.
job 1 ( which will build periodically at 7PM ) will call 2 jobs job_pipeline1_1 and job_pipeline2_1.
job1
job_pipeline1_1 -- job_pipeline1_2
job_pipeline2_1 -- job_pipeline2_2
job_final (should be called only after job_pipeline1_2, job_pipeline2_2 are successfull)
job_pipeline1_1 and job_pipeline1_2 are independent of job_pipeline2_1 and job_pipeline2_2 and will run on differnt servers.
job_final should be called only if job_pipeline1_2 and job_pipeline2_2 are successfull in that particular build.
job_final should be in the pipeline.
check this image "http://i.stack.imgur.com/58Upc.png"
Can any one help me in this regard?
Thanks in advance.
You can use Jenkins plugin "Build Flow Plugin" to run your jobs in parallel.
In that case your final job will be executed after completion of parallel jobs.