Wednesday, August 17, 2011

Using Gradle with CloudBees' Maven Repository

CloudBees is one of the best current Platform as a Service providers. And it is one of the few (maybe only one) who provides tools such as Jenkins as a service too. Its Dev@cloud also provides 2GB free Maven repository which could be a perfect solutions for a lot of home-brewed libraries in your company. This article will show you how to use this free repository in Gradle builds.


Uploading to the repository
There are a lot of reasons why you should want to upload your library to the repository.  The most obvious one is managing the dependencies more easily. If you build your libraries with Gradle you can set up uploading to the CloudBees' Maven repository by adding a few more configuration to your build script.

Gradle to CloudBees

There is no magic about this configuration. You just have to use proper wagon library to support webdav protocol and use the right protocol in the URLs. If you write them manually you should check twice that you use "dav" not "webdav" as the protocol specification.
To upload your artifacts to the repository you just run gradle uploadArchives task.

Using the repository
Using the repository is little bit trickier because to make it work you must use the right server realm.
Using CloudBees repository in Gradle script

The only important part is setting the credentials. The resolver needs the same realm as the server which is "accountname repository".

9 comments:

  1. Glad you like CloudBees! Thanks for the interesting post.

    Cheers,

    Sacha
    CEO CloudBees, Inc.

    ReplyDelete
  2. Thank you Sacha,
    It's pleasure to use such a great platform,
    Keep doing the right things right.

    Cheers,
    Vladimir

    ReplyDelete
  3. Do you know how to make gradle use the cloudbees repo so that it does not download the dependencies in every build?

    I have tried setting the maven repo url to the cloudbees public repo already, but it still downloads from maven central.

    ReplyDelete
  4. I'm sorry, but I don't know. I don't think this is a CloudBees specific issue.
    Try to ask on the Gradle mailing list http://www.gradle.org/lists or one of these great guys - http://twitter.com/#!/bmuschko or http://twitter.com/#!/breskeby or the "Gradle father" himself http://twitter.com/#!/hans_d

    ReplyDelete
  5. Great blog post! I did have a small issues in resolving dependencies though. In order to solve this I had to do the following:

    apply plugin: 'groovy'
    ....
    repositories {
    mavenCentral()
    }
    ....

    Only then could I add deps to the dependencies block.

    It's simple but hope this helps someone.
    Regards,
    Marco.

    ReplyDelete
  6. Thanks Marco for pointing out the problem and much more for solving it immediately . I've updated the Gits so everything should be all right know.

    ReplyDelete
  7. absolutely wonderful !! was always wondering how to do something like this. tere is a new v 1.0.0 gradle plugin for cloud foundry. It lets us upload war's to a PaaS provier who uses cloud foundry layer, but it does not solve this problem as well as this solution. thank you.

    ReplyDelete
  8. This has actually been so much informative and wonderful blog from the many perspective, now I'v been intended to see it through more successful ways. See http://best-college-essay.com/ for best essays.

    ReplyDelete
  9. outstanding publish, very informative. We ponder why the opposite professionals of this sector don’t fully grasp this. free amazon gift card codes

    ReplyDelete