I am using promoted build plugin. When jobA is promoted, jobB is triggered.
I want to get rid of delayed approval.
So, my requirement is to delete jobA's latest build or all the builds automatically after certain triggered time if jobA is not promoted
you can't do it juste with promoted build plugîn but you can use an other job who receive the job url and build id in parameters to execute a http request or curl request using the jenkins cli to delete the specific build
Related
All my Jenkins jobs are triggered both by a Github webhook, but also via a scheduled build one per week. The build process is heavily cached to make the webhook CI builds finish quickly.
I would like to add a line to my build script which wipes the cache during the weekly scheduled build, and make it build from scratch. Is there a variable in the build script to identify if a build was triggered by a webhook or schedule?
Maybe the envInject plugin will give you what you need?
This plugin also exposes the cause of the current build as an
environment variable. A build can be triggered by multiple causes at
the same time e.g. an SCM Change could have occurred at the same time
as a user triggers the build manually.
The build cause is exposed as a comma separated list:
BUILD_CAUSE=USERIDCAUSE, SCMTRIGGER, UPSTREAMTRIGGER, MANUALTRIGGER
In addition, each cause is exposed as a single envvariable too:
BUILD_CAUSE_USERIDCAUSE=true
BUILD_CAUSE_SCMTRIGGER=true
BUILD_CAUSE_UPSTREAMTRIGGER=true
BUILD_CAUSE_MANUALTRIGGER=true
I have a setup in my job config. I just want to execute some downstream jobs after job notification plugin invoked from POST Build actions. But downstream jobs always trigger first and followed by job notification plugin is invoked.
Is there any way to run first job notification plugin and followed by downstream job execution?
You can use the Flexible Publish from Jenkins. It maintains the order of execution of post-build actions and also allows you to use a publisher more than once in a build.
https://plugins.jenkins.io/flexible-publish
https://wiki.jenkins.io/display/JENKINS/Flexible+Publish+Plugin
In Jenkins, I have used the Build-time plugin to timeout and abort the build if the build takes more than a certain specified time.
Is there a way to trigger another job immediately when this particular job fails with timeout where I can make my work process more efficient.
You can accomplish this by installing the Parameterized Trigger Plugin on Jenkins.
(https://wiki.jenkins.io/display/JENKINS/Parameterized+Trigger+Plugin)
Once installed, as a Post-build Action, add the Trigger parametrized build on other projects, from here you can select the Failure option that you need to trigger the next job.
There are two jobs in my jenkins server
job1 : build every 10 minutes to scan the events, if happens it triggers the downstream job2
job2 : normal job mostly run once in the case.
Problem:
too many useless jenkins build for job1 in the UI since it runs frequently.
It will be good if the build can be discarded if it doesn't trigger the downstream job.
Solution so far:, using Discard Old build plugin in post build action is one direction, but no clue how to get it works nicely.
With the hints from #JamesD's comments, I can use several plugins to achieve this
Archive artifacts Plugin: to archive the param.txt files which is used to path to downstream jobs
Groovy Postbuild job Plugin: add the groovy script to check whether the param.txt exists or not. The build will be set to Abort if it doesn't exists
Discard Old Builds Plugin: will discard the Abort build
Is it possible to schedule a build promotion?
The only way I can think of is to create a second upstream job, lets call it the 'Scheduled Promotion Job'
In the Scheduled Promotion job create a promotion which has the promote immediately once the build completes, and schedule it's build to run according to the schedule you want the downstream job to be promoted by.
In the actual downstream build tell it to promote when the following upstream promotions are promoted, and enter the job name of the Scheduled Promotion Job.
To put it another way, tell your build to watch up upstream job for promptions, and put the schedule in the upstream job.
I just tried this with some test projects on my test jenkins server and it worked a treat.