Looking for post-receive githook puppet environments examples

Hi,

In other git environments, I'm able to have the git server perform a post-receive githook to push user branches out to the puppetmaster:/etc/puppet/environments/branchname.

Stash githook support is different so I'm running into an issue where I have not seen any good examples of this workflow.

Thanks,

Alan

5 answers

Hi Alan,

If you need to you can certainly use raw Git hooks on the Stash server. But otherwise, or in general, we recommend using our Repository Hooks:

https://developer.atlassian.com/stash/docs/latest/how-tos/repository-hooks.html

Forgive the naive question - are you just looking to mirror the repository to your puppet environment?

https://marketplace.atlassian.com/plugins/com.englishtown.stash-hook-mirror

Cheers,

Charles

Hi Charles,

I would like to push branches out to various servers and directories. Production, nonproduction and user server/dir pairs. I'm moving towards git-flow and trying to to figure out user branching and testing.

Thanks,

Alan

Hi Alan,

My apologies - I'm not all that familar with exact mechanics of Puppet. Can/does puppet do polling/fetching to receive updates? Or will you need to push to the puppet servers from Stash? If the latter is the mirror plugin linked above enough or if not then why?

Sorry for the 20 questions, I just need to understand exactly what you're trying to do.

Charles

Hi Charles,

I have old post-receive githooks that ssh from the git server to the puppet servers and perform a 'git pull'. Pretty basic stuff.

Alan

Thanks Alan, that helps.

One option would be to just use raw Git hooks, putting the SSH key on the filesystem somewhere. You could use the External Hooks plugin as a mechanism to launch the script if you want per-repository configuration.

Alternatively you could either the mirror plugin mentioned above, enabling HTTP on the puppet server, or setup an SSH mirror with the Mirror Manager.

Another option would be to send a webhook to the server, which listens on HTTP and then does the fetch that way.

Do any of those options sound appealing/useful?

Charles

Hi Charles,

External Hooks should work great for me. Is there a document of exposed environment variables that can be used in the plugin environment?

Thanks!


Alan

Hi Alan,

There are the three input parameters listed on the marketplace page:

Specified executables will receive "$from_ref $to_ref $ref_name" lines on stdin (see "man githooks").

For the environmental variables, the best place is to go directly to the source:

https://github.com/ngsru/atlassian-external-hooks/blob/master/src/main/java/com/ngs/stash/externalhooks/hook/ExternalPostReceiveHook.java#L55

Cheers,

Charles

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

175 views 20 8
Join discussion

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