Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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 to write a scriptRunner script to check for links in the directory in BitBucket

Hi there,

I have the case where a directory that's committed to BitBucket only contain links that's pointing to some of the share in the filesystem.  How can I write a pre-hook script in scriptRunner to check for all the links and make sure those links are from a defined/dedicated location and not from somewhere else that we are not expected?

Thank you for your help.

Kha

1 answer

Hi @Kha Hoang ,

Please can you provide an example use case, to help us answer your question?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Hi Robert,

Let's say I have this set of directory

dir1/dir2/file1.txt

dir1/dir2/file2.txt

dir1/dir2/file3.txt ..............> /root/proj/somefile1.txt

dir1/dir2/file4.txt ..............> /root/proj/subpro/somefile1.txt

dir1/dir2/file5.txt ..............> /mylocal/proj/somefile1.txt

As you see file1 and file2 are real files, file3, 4, and 5 are links some other filesystem

I am expect all the links should come from /root; however, file5.txt is from /mylocal/ and I want a pre-hook to fail/reject the commit so that end-user have to go back to fix it.

Thanks,

Kha

Hi @Kha Hoang ,

If I understand correctly, for example:

/mylocal/proj/somefile1.txt

is the contents of file:

dir1/dir2/file5.txt

And you want to verify the contents "/mylocal/proj/somefile1.txt", is correct? Which in this case, it is not, as the contents should read "/root/proj/somefile1.txt"?

Thanks,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Hi @Robert Giddings _Adaptavist_

Your understanding is exactly right.

Thanks,

Kha

Hi @Kha Hoang ,

OK, great.

The ScriptRunner for Bitbucket team are looking into providing examples regarding file checking, for a range of use cases.

I should have an update in the New Year.

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Hi @Kha Hoang ,

Further to my previous answer, we have now published a Script to our Adaptavist Library that shows an example of blocking commits based on file content.

The Script can be found here: https://library.adaptavist.com/entity/block-commits-for-files-containing-content-that-doesnt-match-regex

Kind regards,

Robert Giddings,

Product Manager,

ScriptRunner for Bitbucket

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

246 views 1 2
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you