Christian Bergau
Christian Bergau

Reputation: 646

How can i use Jenkins with Atlassian Stash?

I've just setup Jenkins and i have some Repositories in my Stash. I installed the "Git plugin" in jenkins. I can now enter the repository url but there is nothing to enter my credentials.

It's possible using

http://username:password@mydomain/xx/yy.git 

but that is something i dont want to do.

What else can i do to authenticate?

Upvotes: 12

Views: 18857

Answers (4)

cmyers
cmyers

Reputation: 1110

I am the author of this stash plugin that might help you: https://github.com/palantir/stashbot

Taking selectively from the readme:

To work with Jenkins, you MUST install the following jenkins plugins first.

  • Jenkins GIT plugin
  • Post build task

Next, build and install the plugin using the plugin SDK (more details in the readme)

Next, the stash admin goes into the Stashbot Admin page and creates a jenkins server config - here you give it the URL, username/password, etc details of the jenkins server.

Next, for each repository a "Stashbot CI Admin" link shows up for repo admins. From there you can check the "enabled" checkbox and tell it what branches you want build (via a regex) and what command it should run to do the build (optionally verifies and publishes).

After this point, the remainder is completely self-service. Any repo admin can ask for their project to "have CI" by filling out that form, and the jobs will automatically be created in the jenkins server.

Hope that helps.

Upvotes: 8

Andreas Falk
Andreas Falk

Reputation: 408

Since version 2.0 of "Git Plugin" for jenkins you should be able to directly add the required credentials for both ssh and username/password (based on credentials plugin).

See changelog of Git plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Changelog for details.

For further integration of git and stash regarding pull requests you additionally need the "Stash Webhook for jenkins" add-on in stash and the "Stash Notifier" plugin for jenkins to connect each other.

Upvotes: 4

charleso
charleso

Reputation: 1836

Two things to add to Gareth's answer.

  1. While I agree that using SSH keys are definitely better than hard-coding the username/password, it's worth mentioning that Stash (currently) scales better with HTTP when it comes to CI. If you have quite a few builds we generally recommend using HTTP. We are currently extending our Git cache support to support SSH so this no longer an issue.

  2. Somewhat related, you might be interested in watching and voting for the following feature which will make it easier to create CI specific keys.

Lastly having build icons show up in Stash is surprisingly handy, and you should have a look at the following plugin if you haven't already:

https://github.com/jenkinsci/stashNotifier-plugin

Upvotes: 5

gareth_bowles
gareth_bowles

Reputation: 21130

Set up an SSH key for the user that runs your Jenkins builds and add it to the repository's SSH keys in Stash. See the Stash docs for instructions.

Upvotes: 6

Related Questions