Jenkins - Not to have failed upstream job if downstream job fails - jenkins

I have a master job which triggers multiply downstream jobs. If some of the downstream jobs fail, I don't want to have failed upstream job. Is there any condition I could set?
Because of that one failed job, I have this status of upstream job, and I want it to be success.

Ok if you want the the downstream jobs are success or not and you don't want to wait until those finish. then you can use in your master jobs in build job command propagate: false, wait: false

Related

Concatenated jobs in Jenkins

I have to solve the following problem:
I have a job A in Jenkis. In one of the stages another Job B is started by the "job build" command.
For Job A to finish, it needs to wait for Job B to finish.
The problem is that Job B does not start because it is waiting for Job A to finish.
I'm using pipeline script in all Jobs.
I imagined that using the command " build job: 'my Job', propagate: true, wait: true" Jenkins would start Job B and after completion of B, it would return to complete Job A
workflow example
I'm assuming you just have one executor configured in your Jenkins Server/Slave. Hence Multiple builds are unable to run at the same time, which causes your deadlock.
In order to increase the executor count follow the following instructions. If you are just using the master to build. Go to Dashboard > Manage Jenkins > Configure and increase the executor count.
If you have slaves go to Dashboard > Manage Jenkins > Manage nodes and clouds click on the edit icon on the Slave and increase the executor count(more than 1) for slaves.

Jenkins pipeline how to detect downstream build status when using parallel()?

I have a pipeline that invokes a couple hundred runs of a downstream job in a parallel block. The downstream job contains a check that may abort the job.
How can I check the build status of the downstream jobs ran in the parallel block? Ideally, the parallel step returns the status of each downstream build in a map or something, but as far as I can tell it returns only a single build status. In my case, if downstream jobs have been SUCCESS, FAILURE, and ABORTED, the upstream build sets it's status as ABORTED.
currentBuild.status and currentBuild.currentResult both seem to have the wrong status set, and if I catch the exception thrown from the parallel step, it's just a hudson control flow exception that doesn't let me know the status of the downstream build.
What is the best way to get the correct downstream build status from jobs invoked from the parallel step?

Jenkins get URL of Downstream Job without Waiting

How do I retrieve the URL of a Jenkins downstream job without waiting for the job to finish? I can access the downstream job in the Jenkins web interface, but I cannot retrieve the URL immediately in the upstream pipeline.
my_job = null
my_job = build job: 'Downstream Job', wait: false, propagate: false
my_job_url = my_job.getAbsoluteUrl() // my_job is still null
Is this not possible?
Given what #roman said in the comment, JENKINS-31392 is the best workaround.

How to get the status of child Jenkins Job from parent Jenkins job

I am currently running 2 Jenkins jobs where one Jenkins Job (Job A) calling another Jenkins Job (Job B) by using "when builds promote". Once it is approved manually, then Job B job will get triggered. After this step, I need the scenario like I would like to get status from Job B in Job A.
If my Job B fails then Job A should fail or vice versa. Any help!
You are missing the fundamentals of how Jenkins works. If an upstream job (job 1) is successful and the downstream job (job 2) fails, Jenkins is doing its job correctly by showing the actual statuses of the jobs (i.e., job 1 is green and job 2 is red).
If the upstream job fails then the downstream should never kick off in the first place, so you won't have to worry about that. This is how Jenkins was designed to work.

Jenkins: how to stop downstream projects when upstream is aborted

I have an upstream project in Jenkins which calls in sequence some downstream projects with the "Trigger/call builds on other projects" plugin.
How can I automatically abort a build of any downstream project when I perform the aborting of the upstream project?
If the upstream is aborted, the downstream is still running and I want a different behaviour.
Thanks.
As mentioned in my comment, you can have downstream jobs listen to upstream jobs instead of having upstream jobs trigger downstream jobs. When it comes to parameters, the following groovy code example can be used to retrieve them:
def up_stream_cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause)
if (up_stream_cause != null ) {
def up_stream_run = up_stream_cause.upstreamRun
def parameters_action = up_stream_run.getAction(ParametersAction)
def parameters = parameters_action.getParameters()
}
Alternatively, you can of course simply build the downstream build during the upstream build using the following groovy code:
build job: 'job_name',
parameters: [
[
$class: 'StringParameterValue', name: 'parameter',
value: 'value'
]
]
Both of those solutions allow you to not trigger a downstream build when your upstream build fails, aborts or is unstable.
You can review:
https://wiki.jenkins.io/plugins/servlet/mobile?contentId=36603009#content/view/36603009
Pipeline jobs can by stopped by sending an HTTP POST request to URL endpoints of a build.
BUILD ID URL/stop - aborts a Pipeline.
BUILD ID URL/term - forcibly terminates a build (should only be used if stop does not work.
BUILD ID URL/kill - hard kill a pipeline. This is the most destructive way to stop a pipeline and should only be used as a last resort.
This last option is quite effective

Resources