I have one main Job on Jenkins.
I also created two jobs:
One job for scm changes build
One for Scheduled Build
In both job I gave the same configuration file as well as workspace.
I just give the name of job different.
Now from the main job through script I'm triggering SCM changes build which is success.
Again from the main job through script I am triggering Scheduled Build which is success.
When both trigger is started from main job, as same time that is SCM changes and scheduled build.
I am getting error due to in both job I gave the same workspace.
How to decide through script from main job when Scheduled build is over then start SCM change build?
Trigger the SCM change build from the scheduled build instead of the main job, using the "Trigger / call builds on other projects" option in the main job's build steps.
Related
How to trigger build pipeline job in Jenkins after some successful builds of another 5 jobs? I tried to use Build trigger but it work only for one successful build job, but not for all five of them.
I created a free style job in Jenkins. I configured Poll SCM and Build periodically for that job.
If both Poll SCM and Build periodically triggers build at the same time, which build runs first?
You can see in hudson/triggers/Trigger.java, how SCMTrigger or TimerTrigger are used:
The cron build is checked first: if it applies, it will check if there is an SCM poll and call it (unless one is already running: "synchronous polling has detected unfinished jobs, will not trigger additional jobs.").
If there is no SCM polling, the cron build will proceed.
So SCM polling has priority: even if a build periodically starts, it would still trigger a poll.
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
How can a job A trigger a job B, such that job B will poll its SCM and then decides wether the actual build would be started or not?
Here is my 'real world' setup: I have a job called GIT_PULL which is using Jenkins DSL to create child jobs depending on sub folders in the repository content. Those child jobs poll the SCM itself but with the option 'Polling ignores commits in certain paths' to ensure they were just triggered, when their sub path has changed.
The current state is that all the child jobs poll the SCM theirselves every H/5 minutes and run independently of their parent job GIT_PULL. However I need to know in GIT_PULL if after a SCM change all child jobs has run fine. But when I switch the polling in the child jobs off and trigger all child jobs in GIT_PULL, they will all run no matter if their repository sub paths has changed or not.
So how can I trigger all child jobs in GIT_PULL, waiting for their result and such that the child jobs will check SCM changes before they will actually run?
Yess - The Multijob Plugin will do the trick.
Within a MultiJob you can define downstream jobs to start but to Build only if SCM changes (that is the exact option name) occur in the downstream project.
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.