Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to block merge PR by schedule?

Peter Bogdanov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 18, 2023

Hi all,

Our releases in Jenkins take around 1h to build. We have release day and time, let say Mon from 3PM to 8PM, if any PR merges in this time window, build fails and need to be started again. I need to prevent any merges to develop and release branches during this time window. Any ideas how to achieve that?

 Thank you,

Peter

3 answers

0 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2023

Write a one-line merge check in Groovy for ScriptRunner!

The script itself should just get the current system time and test if it is not within the unwanted period. We develop an app that heavily relies on hooks and merge checks, and in our experience merge checks are absolutely reliable.

0 votes
Hyrum Steffensen _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2023
0 votes
Hyrum Steffensen _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2023

Hello Peter,

I did a Google search for, "jenkins automatically build on failure" and found an interesting suggestion on Stack Overflow for a Jenkins plugin. See the following links for further details:

https://stackoverflow.com/questions/31870464/how-to-trigger-a-job-if-the-currently-running-job-failed

https://plugins.jenkins.io/downstream-ext/

It may pay to check out other plugins for Jenkins.

An alternative would be to use a Jira scripting tool as found on the Atlassian Marketplace such as Scriptrunner, JMWE or Power Scripts. Perhaps there are some Jenkins REST endpoints you could use in a script to restart the build depending on your use case. However, in practice, I would prefer to do this in Jenkins. An error handler is always better than a scheduler.

Regards,

Hyrum

 

Please note that I am a product engineer for Power Scripts and I work for Appfire.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.8.2
TAGS
AUG Leaders

Atlassian Community Events