how to execute Jenkins job in non-sequence manner? - jenkins

I have 10 jobs in jenkins 1 to 10, but I want to execute the job number 5th and 10th first and the rest others and so on, how can I achieve this?

If you want to execute one job after another has run, just configure a build trigger to execute when another project has been built. Jenkins will mark the jobs as upstream/downstream projects.
If you want to prevent that some job executes while some other job is running (even if triggered manually on the UI), use the Lockable Resources Plugin.

Related

Force Jenkins to run only one pipeline job and put rest all in queue

I would like to build only one project at a time in entire jenkins server. I have tried Jenkins throttle concurrent plugin and lockable resource plugin but no luck. As lockable resource plugin doesn't give me option to lock in pipeline job.
I have 3 Jenkins pipeline jobs (job have pipeline script):
JOB1
JOB2
JOB3
which has some common thing at beginning of the job (clearing content).
Running one by one manually doesn't have any problem if job completed but if JOB1 is building and JOB2 starts in between then it interrupts to JOB1 and build fails for JOB1.
Even when I start jobs using CLI, you never know which job might be running. So, I'm looking for solution to block JOBY if JOBX is running (X, Y can be 1,2 or 3) and allow only one job to run in entire Jenkins server. Like I said, throttle concurrent plugin gives customization option only for respective job instead of for multiple jobs?
Can anyone suggest some solution for multi pipeline jobs block to run only once?
Install Build Blocker Plugin
In configuration of JOBY check "Block build if certain jobs are running".
Put JOBX name in Blocking Jobs text area, each job on new line.
Note, you can also use regex to define in single line jobs having the same prefix but ending with different numbers.

Run jenkins job without triggering downstream jobs

I have a jenkins job with a couple of downstream jobs which are triggered upon the job finishing correctly.
There are times when I want to run the initial job without triggering the downstream jobs. Is this possible?
It sounds like the conditional build step plugin might be of help. You can configure it to trigger other jobs based on various conditions, like so:
Here, the conditional build step has been configured to run downstream-job if foo.txt exists in the current workspace.

How do I run a Jenkins job on a weekend, AFTER another job has completed?

I have a job in Jenkins that I only want to run on Saturday, but it must only be ran after another job is finished (this is a report job, so data must be in place).
I understand how to use the Jenkins con expressions, but can I chain that in sequence with another job? The idea being once the first job is completed, the date is checked. If it's Saturday, run the second job.
Can Jenkins do that, or is it something I need to write via a script?
You can use Jenkin's Flexible Publish Plugin to set conditional build step:
https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin

jenkins: promote before job ends

I'm trying to configure a job in jenkins in a way that the promotion process (Promoted builds plugin) happens in the middle of a run. The point is that there are some annoying tasks like javadocs, sonar integration,... that can be run even after the promotion process, therefore I would like to make the build, run all needed tests and then promote the build automatically. Other tasks can run after the promotion process.
Do you know how I can implement this using the Promoted builds plugin?
Thanks in advance for the help.
No, Promotions only run on completed builds. If you want to run it in the middle of the job, then it's a build step, not a promotion.
You can either configure build steps for your actions (same actions as promotions). You can even call other jobs, and wait for them to complete (or not wait).
Or you can configure your "after promotion" tasks as a second promotion that is executed after the first one.

Jenkins: multiple jobs with one shared resource

So I have a dynamic number of jobs which all have only one build step.
at some ("random") point of its execution, each job run some application which couldn't have more than one instance at a given time.
In general I do want parallel run of the jobs. but I still need some synchronization when two or more jobs trying to run the above application at the same time.
I though about using the Locks and Latches plugin , but I can't see how this will help me in my situation.
Ideas will be more than welcomed!
Run the application from a separate job (let's call it APP_JOB) that you would invoke via Parametrized Trigger Plugin (as a build step, not as a post-build step) from your other jobs, with an option to wait for it enabled. By default Jenkins won't run parallel instances of APP_JOB.

Resources