It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I debug hooks created with ScriptRunner? Edited

I added a pre-receive hook using the Protect Git Refs type, following the condition described in the accepted answer here.

Condition:

def commits = refChanges.getCommits(repository)

def regex = "[A-Z]{2,9}-\\d+\\s[A-Za-z]+.*"

commits*.message.any { message ->
   	!(message  ==~ /${regex}/)
}

 

First, the script editor in ScriptRunner gives me an error on the commits.message line, saying "expecting '}', found '-' @ line 5, column 32." I copied and pasted the condition directly from the linked answer, so I'm not sure if it's actually supposed to be a greater-than symbol that got translated or what.  But it did let me save, so I tried to push a commit, and got this message in my git bash window:

"remote: A pre-receive hook failed to execute properly - contact an Administrator"

So my question is, how do I go about debugging issues with hooks created via ScriptRunner? Is there a log somewhere?

 

(EDIT: I changed it to an actual greater-than symbol, and it works now. But I'd still like to know how to debug hooks.)

Also - is there a way to add line breaks to the error message? What I get in git now is this:

remote:
remote: =====================================================
remote: Your commit message must start with a Jira number. Use git commit --amend to update your commit message. (<esc> :wq <enter> to get out of Vim)
remote: =====================================================
remote:

 

I'd like to get something like this:

remote:
remote: =====================================================
remote: Your commit message must start with a Jira number.

Use git commit --amend to update your commit message.

Then type (<esc> :wq <enter> to get out of Vim)
remote: =====================================================
remote:

 

 

1 answer

Hi Esther.

What do you mean you want to debug hooks?

Do you debug any other SR feature? If so how?

The word "debug" is quite broadly used, and I want to be 100% sure I know what you mean before I commit to an answer.

Cheers!

Dyelamos

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 03, 2019 in Marketplace Apps

How to estimate projects more accurately?

Gaining insight into your team’s effectiveness and choosing the right estimation technique.   Estimating projects is hard. It is because people have the tendency to underestimate the time thin...

288 views 2 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you