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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

649 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot