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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,639,057
Community Members
 
Community Events
196
Community Groups

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

0 votes
Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 06, 2021

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

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 20, 2021

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

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 22, 2021

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

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 19, 2022

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

Thank you very much.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events