1

I have some hooks I wanted to implement on my repo, written in Shell Script and Python. The issues I have though is that under normal circumstances, The server repo would just get a modification.

It seems adding a CMS such as bitbucket has convoluted the simplicity that is: modify .git/hooks/update by creating a market place where I have to buy/acquire various utilities.

It seems that it isnt as simple now.

Given:

|-> scripts
    |->my_python.py
|-> .git
    |-> hooks
        |-> update.sample

I want to reference my_python.py from within my update script.

I can easily see it as use python $git_working_directory/scripts/my_python.py of sorts, but in bitbucket, it is just not as simple to reference this.

My desired end goal is to fire this python script when the server creates or deletes branches.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Fallenreaper
  • 10,222
  • 12
  • 66
  • 129
  • Are you using Bitbucket cloud or self hosted? – eeijlar Jun 14 '18 at 06:58
  • @eeijlar Im not sure. I think it is on one of our servers, but i noticed a plugin section or the atallasian marketplace, and sometimes when we sign in, it looks like there is a route to our login page. So I am not 100% sure how much is hosted on our end vs how much is processed on Atallasian. – Fallenreaper Jun 18 '18 at 13:27
  • *bumps hoping this gets more views* – Fallenreaper Jun 19 '18 at 14:08
  • Does your clone url contain bitbucket.org? If it does, then it's most likely cloud instance. – eeijlar Jun 28 '18 at 16:06
  • bitbucket.test.com, so it is an instance under the test domain. What I am going to do is create a polling utility in Jenkins to check for changes because the course of action i want to take doesnt exist unless I want to have it ping a URL endpoint, which I honestly do not want to expose. Its not the answer I want, but it is one I can do.... – Fallenreaper Jun 28 '18 at 19:07

1 Answers1

0

This might work, I am not sure but it's worth a try. Browse to your repository in Bitbucket, and select settings (need admin permissions on project/repo), then select Repository Details. On that screen you should see an item 'Location on disk', something like:

Location on disk   /var/atlassian/application-data/bitbucket/shared/data/repositories/1026

Log onto the server (bitbucket.test.com, assumes you have access to the bitbucket server), then as the 'atlbitbucket' user, go to the location provided by 'Location on disk':

cd /var/atlassian/application-data/bitbucket/shared/data/repositories/1026

In here you will see the standard hooks

hooks/pre-receive.d

You can drop your update.sample in here.

Later versions of Bitbucket introduced webhooks, which may be of use.

eeijlar
  • 1,232
  • 3
  • 20
  • 53
  • I was thinking this, but my boss informed me that giving access to us from IT for the box is like pulling teeth. They seem to not want us to touch this repo box at all. I was looking at webhooks which I thought might be useful, but id need to expose a port and process it. The issue then comes from "where do i host this?" if for the most part, I dont have access to these machines. The path my boss thought would be useful is a bash script which runs every 5 minutes through jenkins. I HAVE that, just need to do some sort of storage for branch maintaining. ill check git branches with a dump file. – Fallenreaper Jul 08 '18 at 13:35
  • Then the only option I can think of is to write your own hook plugin : https://youtu.be/oU7i7hhiUQ8 – eeijlar Jul 08 '18 at 16:51