Run jenkins job without triggering downstream jobs - jenkins

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.

Related

how to execute Jenkins job in non-sequence manner?

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.

Is it possible to schedule a step in Jenkins pipeline?

What ideally I need to do is run a Jenkins pipeline that will run immediately after I start the execution , checking out code, running a build but just running the deployment in a particular date/time. So Would it be possible to schedule a particular step in jenkins pipeline? This step would be executed at date/time provided by user input. If that’s not possible is there any alternative way of doing it?
The is no such way to schedule the steps of the Jenkins Job. But the Following approach may help you to achieve what you are trying to do.
Step-1: Install "Schedule Build Plugin" which will provide you a capability to schedule the job to run on certain data and time.
Step-2: Create a pipeline job with the code that you want to execute at a certain date and time. (Note: You will not schedule this job at this time)
Step-3: Remove the pipeline code that you already copied to another pipeline job and add a build step to schedule the build on the second pipeline that you will create in step-2.

Jenkins: how to I automatically restart a triggered build

I have one Jenkins job that triggers another job via "Trigger/call builds on other projects."
The triggered downstream job sometimes fails due to environmental reasons. I'd like to be able to restart the triggered job multiple times until it passes.
More specifically, I have a job which does the following:
Triggers a downstream job to configure my test environment. This process is sensitive to environmental issues and may fail. I'd like this to restart multiple times over a period of about an hour or two until it succeeds.
Trigger another job to run tests in the configured environment. This should not restart multiple times because any failure here should be inspected.
I've tried using Naginator for step 1 above (the configuration step). The triggered job does indeed re-run until it passes. Naginator looks so promising, but I'm disappointed to find that when the first execution of the job fails, the upstream job fails immediately despite a subsequent rebuild of the triggered job passing. I need the upstream job to block until the downstream set of jobs passes (or fails to pass) via Naginator.
Can someone help me know what my options are to accomplish this? Can I configure things differently for the upstream job so it relates to the Naginator-managed job better? I'm not wed to Naginator and am open to other plugins or options.
In case its helpful, my organization is currently using Jenkins 1.609.3 which is a few years old. I'd consider upgrading if that leads to a solution.

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.

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.

Resources