Pushing changes from Shippable to Github

If you use Shippable as your Continuous Integration server on an open source project hosted on Github you will find that by default you cannot push any changes back to Github such as when you increment a version number and wish to push the changes back. This is because Shippable uses HTTPS for public Github repositories so trying to push changes back to it will require a username and password.

Solution

The solution is actually simple and requires two steps, firstly installing the the deployment key in your user or repository and then switching git over to ssh rather than https.

Deployment key

You can find your shippable deployment key on the right hand side of your account, this is a standard SSH public key, copy this key.

You can either add this key to your repository or to your user (or another user if you so choose) that has access to your repositories. Be aware though that Github restricts the re-use of keys so if you add it to your repository then you can only have it on a single repository and shippable only provides a single deployment key. I personally would recommend creating another Github account that shippable can use and controlling access to the repository through that account with the deployment key.

Adding the key is easy, go to your settings on your Github account and choose SSH Keys on the left and click 'Add SSH Key' give it a title and paste the key into the box.

Shippable configuration

Shippable uses a yml file (shippable.yml) located in the root of your project, in the before_script section you just need to add the following line:
 - git remote set-url origin git@github.com:$REPO_NAME.git

To confirm that the URL has changed you can add the following line to confirm the new origin url.
 - git config --get remote.origin.url

$REPO_NAME is an environment variable provided by Shippable that resolves to the plain repository path, e.g. for the Twitter commons repository using the URL https://github.com/twitter/commons.git $REPO_NAME resolves to twitter/commons

Comments

  1. Thanks for the write up, I just go bit by this trying to push build numbers for tags.

    Maybe we should add them to the docs https://github.com/Shippable/docsv2

    ReplyDelete
  2. $REPO_NAME needed to be changed to $REPO_FULL_NAME for me and your post worked out. Thanks

    ReplyDelete
  3. Free easy & simple way to learn programming online we provide niit projects, assignments, cycle tests and much more..
    visit ====>>> https://githubhelp.blogspot.in

    ReplyDelete

Post a Comment

Popular posts from this blog

Gradle and the parent pom

Goodbye Shippable Hello ... CircleCI