如何让CloudBees Jenkins Grails构建从私有maven存储库中获取JAR?

时间:2013-08-05 22:08:12

标签: cloudbees

我有一个Grails(2.2.3)项目,我试图在CloudBees上构建。该项目使用第三方库,该库目前未在任何公共maven仓库中托管。因此,我需要将这个库jar发布到一个私有的maven仓库,这个仓库是在CLoudbees上构建的Jenkins可以访问的。

我已经成功构建了第三方jar并将其发布到我计算机上的本地maven仓库中。

根据http://wiki.cloudbees.com/bin/view/DEV/CloudBees+Private+Maven+Repository的指示,我已将第三方jar发布到我的cloudbees版本和快照存储库。

然而,这对于Cloudbees Jenkins构建来获取单个jar是不够的。

我知道我的构建设置中的其他所有内容都很好,因为如果我将第三方jar添加到我的grails应用程序的/ lib /文件夹中,则构建会通过,但是将依赖项添加到/ lib /文件夹中不好的做法,所以我想避免它。

以下是我在尝试构建时看到的错误:

| 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
        ::::::::::::::::::::::::::::::::::::::::::::::

基本上,Jenkins不知道它必须查看Cloudbees快照或发布存储库。

本文件:http://wiki.cloudbees.com/bin/view/DEV/Sharing+Files+with+Build+Executors 说您可以配置CloudBees Jenkins构建以使用您选择的maven settings.xml文件,但CloudBees grails Jeknins构建似乎不提供设置自定义maven settings.xml的方法

我需要做些什么才能让Cloudbees Grails Jenikns Build从cloudbees快照或发布存储库中获取jar?

2 个答案:

答案 0 :(得分:2)

我有一个非常类似的在线示例,应该包含您需要的大部分内容:它实际上是一个Android Gradle构建,它使用来自CloudBees上的私有(发布)Maven仓库的库。

实际构建位于:android-gradle-google-apis

项目构建文件位于:build.gradle

要获取CloudBees托管的仓库,您只需添加以下内容:

repositories {
    mavenCentral()
    maven {
        url "https://repository-partnerdemo.forge.cloudbees.com/release/"
    }
}

如果您使用的是DEV @ cloud,则无需对settings.xml执行任何操作,因为这会自动配置为允许您访问私有存储库。如果您还想在本地构建,那么您需要在本地settings.xml中添加服务器条目,如CloudBees Private Maven Repositories所述。

有一个示例构建,显示如何配置构建以在此处将库安装到您的私有存储库:maven-android-sdk-deployer

有一份文件在developer.cloudbees.com上解释了所有这些背景。

答案 1 :(得分:0)

最后弄清楚出了什么问题:我需要在BuildConfig.groovy中拥有maven凭据

CloudBees支持工程师在解决这个问题上非常有帮助。

在我的grails-app / conf / BuildConfig.groovy中,我需要这个:

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'
    }
}