How to get jenkins to build regardless of no changes in the repository?

253 Views Asked by At

I have a bitbucket webhook set to trigger jenkins job on a different bitbucket repository. The problem here is that, because there are no changes done for the repository which the job is supposed to run on, the job doesn't start. So how could I get jenkins to start building regardless of changes not being done in the repository.

Also if you have better ideas on how to trigger a jenkins build from different bitbucket repository, let me know.

1

There are 1 best solutions below

0
M B On

You could have a polling job that runs regularly (every 3 minutes for example) and checks if the BB repo has any changes pushed to it. If that is the case, go ahead and trigger the build for the other BB repo.

If you just want a certain set of automated steps to run and you don't pass in any build parameters that will vary per build, this is good enough. Jenkins will automatically cancel any builds that are triggered if they are similar to the one that is currently running.

At the end of the build, use the BitBucket API to set the status of the first repo (triggering repo) commit to "Success" or "Failed". This way, you can have an if condition in the polling job that checks if the latest commit has been built (by checking if the commit has a build status). If so, ignore that commit so that the same thing doesn't keep getting built over and over.