Sometimes not showing input parameter fields under "Promotion Status" on jenkins server - jenkins

I have configured two jobs on jenkins server. One for creating package and second for deploying package to respective server. And promoted build from first job to second job. Facing issue on upgradtion of jenkins from 2.320 to 2.344. Sometimes promotion status not showing input field for deploy job. I'm attaching images for reference.
Sometime getting following UI on promotion status
Should show everytime:

Related

How to combine multiple build started Jenkins messages into one email

I am using Jenkins, Gerrit and repo for my project. Often times I make code changes that span across git repositories (all managed through repo). When I submit a CL it triggers multiple Jenkins jobs (pre-submits, cross reference checks, linters...) which sends flurry of build started emails and finally one email with +/-verified status. Wondering if it is possible to combine all the build started emails into one (just like the final verified status email)
I would suggest you to use Pipeline where only one job will be triggered as part of Gerrit trigger and the Pipeline will take care of calling all other jobs and update the Gerrit with the final message.

Storing Jenkins pipeline job metadata?

Is there a way where to store some metadata from Jenkins pipeline job, e.g:
We have a Jenkinsfile which builds a gradle project, creates docker image and pushes it to google cloud
Then a "Subjob" is launched which runs integration tests (IT) on that docker image. Subjob receives a couple of parameters (one of them - the generated docker image name)
Now sometimes that IT job fails, and I would like to re-run it from the main job view, so idealy:
we have a plugin which renders a custom button in blue ocean UI on the main job
By clicking that button a subjob is invoked again with the same parameters (plugin queries the jenkins api, get params of this job, and resubmits the subjob).
The problem ? How to get/set those parameters. I could not seem to find a mechanism for that, expect artifact storage. I could get away with that by creating a simple json/text file and uploading it as artifact, and then retrieving it in my plugin, but maybe there is a better way?
Stage restart is not coming to Scripted Pipelines so that does not look like ant option.
Maybe you can use the Jenkins API to get the details of the build?
https://your_jenkins_url.com/job/job_name/lastBuild/api/json?pretty=true
Instead of lastBuild you can also use the build number or one of lastStableBuild, lastSuccessfulBuild, lastFailedBuild, lastUnstableBuild, lastUnsuccessfulBuild, lastCompletedBuild
There is a parameters key there with all parameter names and values used in the build.
More details on https://your_jenkins_url.com/job/job_name/api/
Also, any reason you can't use the replay button in the IT job?

Remove unnecessary jobs from build pipeline on Jenkins

I'm a bit new to Jenkins and I'm having an display issue with Build Pipeline plugin. I'm executing some jobs in parallel using JobFanIn Plugin, i.e. the next job in the pipeline will only be executed when all the previous jobs are concluded. However, the Build Plugin believes that all jobs will trigger a new instance of the last job. The execution goes right, but the display isn't.
Bellow is possible to observe what is happening in practice. The GENERATE TEST REPORT job will only be triggered when all TEST jobs are finished and this occurs ok. But since the Build Pipeline plugin expects 3 instances of this job to happen, only one happens and the others appeat as pending forever.Any ideas?
First image displaying what is happening
Second image displaying what is supposed to happen

Jenkins job wait for first successful build of other job

I have a Jenkins job that should not start building until another job has been built successfully at least once. They are not related per se, so I don't want to use triggers. Is there a way to do this?
Some background: I'm using SCM polling to trigger the second job. I've looked at the Files Found Trigger plugin, but that would keep on triggering the second job after the first on has been built. I've also found the Run Condition Plugin, but that seems to work only on build steps, not on the entire build.
Update - The second job copies artifacts from the first job. As long as the first job has never completed successfully, the Copy Artifact step fails. I am trying to prevent that failure, by not even attempting to build the second job until the first job has completed once.
One solution is to use the Build Flow plugin.
You can create a new flow job and use this DSL:
I've used 10 in the retry section but you can use any numbers.
This flow job can be triggered by monitoring the same SCM URL of your second job.
Update, here is a second solution.
You can use the HTTP Request plugin.
If you want to test that your first job has been built successfully at least once, you can test this URL:
http://your.jenkins.instance/job/your.job/lastSuccessfulBuild/
One example:
As my build has never been successful, the lastSuccessfulBuild URL doesn't exist. The HTTP Request changes my build status to failure.
Does it help?
The Block queued job plugin can be used for this: https://wiki.jenkins-ci.org/display/JENKINS/Block+queued+job+plugin

Is there a way to resume from a failed job in Jenkins?

I am using 4 Jenkin jobs for Continuous Build and Deployment.The jobs are created for label creation, build using the label, deploy to server1 and deploy to server2 and so on..
The Create_label build will run the MYSQL query in database and get the label. Create_label job on success will invoke the Build-job with the label and upon successful completion of Build-Job, it will invoke Deploy-server1 job and so on..
If the build fails in Build-Job and after that If I start the 1st Create-Label job then it runs the job and creates the NEW label. I mean running the create-label every time will get you incremental label. I can only get the label from 1st job and then pass to 2nd job. Can anyone suggest how to resume from the failed job with out running the first job and start with second job using the old label created(from the last build in 1st job). any work around to accomplish this type of situation in jenkins.
1.Create-Label
2.Build-Job
3.Deploy-server1
4.Deploy-server2
So it seems, you have 2 issue at the moment:
Issue 1 --> If any job fails, the next time it should skip the successful jobs and restart only from the failed job.
Probable Solution --> You could use Build Pipeline plugin, https://wiki.jenkins-ci.org/display/JENKINS/Build+Pipeline+Plugin , and if the job fails at say second job, then all you have to do is restart the second job from the pipeline and it would continue from there.
Issue 2 --> For job 2, you not only want to restart it but have to take the input, Label Number, from the previous successful job 1, without restarting job 1
Unfortunately, I don't have a clean automated solution for this. The only thing I can think of requires manual intervention, i.e. since this job is parameterized, change the default value of the parameter to the Label Number from the last successful job 1 before restarting it from plugin(The above plugin doesn't ask for parameters while running the job)
or let Job1 login the label number in some centralized location and let job B take the parameter from there instead of taking it from jobA.
Thanks,
Manish Joshi
I am using MultiJob plugin and you can always just click "Resume build" in the parent job to continue from a failed job.
And in this case the parameters for its execution will be all the same as on those previous run which failed.

Resources