简体   繁体   English

Jenkins Artifactory插件无法解决工件

[英]Jenkins Artifactory plugin not resolving artifacts

Artifactory provides a Jenkins plugin and according to the docs it is supposed to Artifactory提供了一个Jenkins插件,根据文档,它应该

resolve artifacts from Artifactory and deploy artifacts and build information to Artifactory. 从Artifactory解决工件,并部署工件并将信息构建到Artifactory。

I published a library to Artifactory and now I'm trying to build a project that consumes that library 我向Artifactory发布了一个库,现在我正在尝试构建一个使用该库的项目

My Setup 我的设定

build.gradle build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
    }
}

Jenkins gradle build-step Jenkins Gradle构建步骤

Runs ./gradlew assemble 运行./gradlew assemble

Gradle-Artifactory Integration : Gradle-Artifactory集成

Enabled, but since I only need/want artifacts to be resolved from Artifactory, I've configured my Artifactory server and resolution repository, but disabled everything else. 启用,但是由于我只需要/想要从Artifactory解析工件,因此我已经配置了Artifactory服务器和分辨率存储库,但禁用了其他所有功能。

My build currently fails with the following error 我的构建当前失败,并出现以下错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find any version that matches com.mygroup:mylib:latest.integration.
     Searched in the following locations:
         file:/var/lib/jenkins/.m2/repository/com/mygroup/mylib/maven-metadata.xml
         file:/var/lib/jenkins/.m2/repository/com/mygroup/mylib/
         https://jcenter.bintray.com/com/mygroup/mylib/maven-metadata.xml
         https://jcenter.bintray.com/com/mygroup/mylib/
         file:/mnt/jenkins/tools/android-sdk/extras/android/m2repository/com/mygroup/mylib/maven-metadata.xml
         file:/mnt/jenkins/tools/android-sdk/extras/android/m2repository/com/mygroup/mylib/
         file:/mnt/jenkins/tools/android-sdk/extras/google/m2repository/com/mygroup/mylib/maven-metadata.xml
         file:/mnt/jenkins/tools/android-sdk/extras/google/m2repository/com/mygroup/mylib/
     Required by:
         My Job:app:1.0-SNAPSHOT

Clearly, gradle is not searching Artifactory for the artifact. 显然,gradle不会在Artifactory中搜索工件。

Question

How can I get the Artifactory plugin for Jenkins to tell gradle to resolve artifacts from my Artifactory server? 如何获得Jenkins的Artifactory插件,告诉gradle解决来自Artifactory服务器的工件? Even just getting gradle to look there would be a start. 即使只是摇摇晃晃地也将有一个开始。

Artifactory is not jcenter. Artifactory不是jcenter。 If your library only deployed to Artifactory, you need to set up your build to take the dependencies from Artifactory. 如果您的库仅部署到Artifactory,则需要设置构建以获取来自Artifactory的依赖项。 You have too ways to achieve it: in Jenkins and in Gradle. 您也有实现它的方法:在Jenkins和Gradle中。

Setting up Jenkins 设置詹金斯

You set up Jenkins to use Artifactory for your dependencies, using the Artifactory Jenkins Plugin . 您可以使用Artifactory Jenkins插件将Jenkins设置为将Artifactory用于您的依赖项。

Install the plugin, setup Artifactory server in the settings and then in job configuration check the "Resolve artifacts from Artifactory" checkbox. 安装插件,在设置中设置Artifactory服务器,然后在作业配置中选中“从Artifactory解决工件”复选框。

Or, setting up Gradle 或者,设置Gradle

Another option might be instructing Gradle to use your Artifactory server as dependencies repository. 另一个选择可能是指示Gradle将您的Artifactory服务器用作依赖项存储库。 Probably something like this will do the job: 大概是这样的:

repositories {
    maven {
        url "http://myartifactoryhost:80801/artifactory/libs-releases"
    }
}

Please note that you need to replace the host and the port and you might also want to change the name of the repository if you prefer to resolve the artifacts from another one (like libs-snapshots ). 请注意,您需要替换主机和端口,并且如果您希望从另一个对象(例如libs-snapshots )解析工件,则可能还想更改存储库的名称。


I am with JFrog , the company behind Bintray and [artifactory] , see my profile for details and links. 我与Bintray[artifactory]背后的公司JFrog 在一起 ,有关详细信息和链接,请参阅我的个人资料。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM