1

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

我已经成功构建了第三方 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?

4

2 回答 2

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上有一份文件解释了这一切的背景。

于 2013-08-09T04:55:18.553 回答
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'
    }
}
于 2013-08-28T05:15:48.627 回答