Reputation: 341
I have a Grails (2.2.3) project which I am trying to build on CloudBees. The project uses a third party library which is not currently hosted in any public maven repo. I therefore need to publish this library jar to a private maven repo that the Jenkins build on CLoudbees can access.
I have successfuly built the third-party jar and published it to my local maven repo on my computer.
As per directions at http://wiki.cloudbees.com/bin/view/DEV/CloudBees+Private+Maven+Repository , I have published the third party jar to my cloudbees release and snapshot repositories.
However, this is not enough for the Cloudbees Jenkins build to fetch the singly jar.
I know that everything else in my build setup is fine, because if I add the third-party jar into the /lib/ folder of my grails app, the build goes through, but adding dependencies into the /lib/ folder is not good practice, so I want to avoid it.
Here is the error I see when trying to build:
| Loading Grails 2.2.3
| Configuring classpath
:: problems summary ::
:::: WARNINGS
module not found: com.singly#singly-sdk;1.0.0-SNAPSHOT
==== grailsPlugins: tried
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/scratch/jenkins/workspace/foobarapp master/foobarapp/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/cache-1.0.0/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/hibernate-2.2.3/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/webxml-1.4.1/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/jquery-1.8.0/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/tomcat-2.2.3/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/database-migration-1.1/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/resources-1.1.6/lib/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/2.2.3/projects/foobarapp/plugins/rest-0.7/lib/singly-sdk-1.0.0-SNAPSHOT.jar
==== grailsHome: tried
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/lib/com.singly/singly-sdk/ivy-1.0.0-SNAPSHOT.xml
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/lib/com.singly/singly-sdk/jars/singly-sdk-1.0.0-SNAPSHOT.jar
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/lib/com.singly/singly-sdk/bundles/singly-sdk-1.0.0-SNAPSHOT.jar
==== grailsHome: tried
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/src/libs/singly-sdk-1.0.0-SNAPSHOT.xml
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/src/libs/singly-sdk-1.0.0-SNAPSHOT.jar
==== grailsHome: tried
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/dist/singly-sdk-1.0.0-SNAPSHOT.xml
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/dist/singly-sdk-1.0.0-SNAPSHOT.jar
==== grailsHome: tried
/home/jenkins/.grails/2.2.3/cached-installed-plugins/singly-sdk-1.0.0-SNAPSHOT.xml
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.grails/2.2.3/cached-installed-plugins/singly-sdk-1.0.0-SNAPSHOT.jar
==== grailsHome: tried
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/plugins/singly-sdk-1.0.0-SNAPSHOT.pom
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.grails/wrapper/2.2.3/grails-2.2.3/plugins/singly-sdk-1.0.0-SNAPSHOT.jar
==== grailsCentral: tried
http://grails.org/plugins/grails-singly-sdk/tags/RELEASE_1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.pom
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
http://grails.org/plugins/grails-singly-sdk/tags/RELEASE_1.0.0-SNAPSHOT/grails-singly-sdk-1.0.0-SNAPSHOT.jar
==== localMavenResolver: tried
/home/jenkins/.m2/repository/com/singly/singly-sdk/1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.pom
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.m2/repository/com/singly/singly-sdk/1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.jar
==== mavenCentral: tried
http://repo1.maven.org/maven2/com/singly/singly-sdk/1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.pom
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
http://repo1.maven.org/maven2/com/singly/singly-sdk/1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.jar
==== localMavenResolver: tried
/home/jenkins/.m2/repository/com/singly/singly-sdk/1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.pom
-- artifact com.singly#singly-sdk;1.0.0-SNAPSHOT!singly-sdk.jar:
/home/jenkins/.m2/repository/com/singly/singly-sdk/1.0.0-SNAPSHOT/singly-sdk-1.0.0-SNAPSHOT.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: com.singly#singly-sdk;1.0.0-SNAPSHOT: not found
::::::::::::::::::::::::::::::::::::::::::::::
Essentially, Jenkins does not know that it has to look in the Cloudbees snapshot or release repositories as well.
This document: http://wiki.cloudbees.com/bin/view/DEV/Sharing+Files+with+Build+Executors says that you can configure a CloudBees Jenkins build to use a maven settings.xml file of your choice, but the CloudBees grails Jeknins build does not seem to provide a way of setting up a custom maven settings.xml
What do I need to do to get the Cloudbees Grails Jenikns Build to fetch jars from the cloudbees snapshot or release repositories?
Upvotes: 1
Views: 723
Reputation: 341
Finally figured out what was wrong: I needed to have maven credentials in the BuildConfig.groovy
CloudBees support engineers were quite helpful in figuring this out.
In my grails-app/conf/BuildConfig.groovy, I needed to have this:
grails.project.dependency.resolution = {
repositories {
...
mavenRepo "https://repository-foobar.forge.cloudbees.com/release/"
...
}
credentials {
realm = "foobarrealm"
host = "repository-foobar.forge.cloudbees.com"
username = "foobarusername"
password = 'foobarencryptedpassword'
}
}
realm
is what your browser shows you in the username/password challenge popup when you try to access resources in the maven repo you are trying to reach. This was vital, and I found information about it here: http://grails.1312388.n4.nabble.com/BuildConfig-dependencies-on-Secured-Maven-repos-td4390955.html host
is my maven repo hostusername
is my maven repo usernamepassword
is the encrypted maven repo password. Its safer than putting a plaintext password. Details about generating an encrypted password are here: http://maven.apache.org/guides/mini/guide-encryption.htmlUpvotes: 0
Reputation: 91
I have a very similar example online that should have most of what you need: it's actually an Android Gradle build that uses libraries from a private (release) Maven repo on CloudBees.
The actual build is here: android-gradle-google-apis
The project build file is here: build.gradle
To pick up the CloudBees-hosted repo, you just need to add the following:
repositories {
mavenCentral()
maven {
url "https://repository-partnerdemo.forge.cloudbees.com/release/"
}
}
If you are using DEV@cloud, there is no need to do anything with settings.xml, as this is automatically configured to allow you to access your private repos. If you also want to build locally, then you will need to add a server entry to your local settings.xml, as described here CloudBees Private Maven Repositories.
There is an example build that shows how to configure a build to install the libraries to your private repo here: maven-android-sdk-deployer.
There is a document explaining the background to all this on developer.cloudbees.com.
Upvotes: 2