无法解决CentOS7上Jenkins在dependencyManagement中定义的工件

时间:2017-08-10 15:27:08

标签: maven jenkins

我让Jenkins在防火墙后面的CentOS7盒子上运行 我正在使用Jenkins安装的Maven版本。 我在Jenkins的全局settings.xml文件中配置了一个镜像,指向我们的内部Artifactory服务器。

我的依赖项部分中定义的依赖关系会被拉下来。但是, dependencyManagement 部分中的依赖项失败,错误为 ReasonPhrase:Forbidden

奇怪的是,如果我在Jenkins框的工作区中从命令行运行构建,一切运行正常。

错误输出:

Parsing POMs
    using global settings config with name GlobalMavenSettings
    Replacing all maven server entries not found in credentials list is true
    Failed to transfer Could not transfer artifact org.springframework.cloud:spring-cloud-heroku-        connector:pom:1.2.2.RELEASE from/to artifactory 
    (http://artifactory.cos.dev:8081/artifactory/repo): Access denied to: http://artifactory.cos.dev:8081/artifactory/repo/org/springframework/cloud/spring-cloud-heroku-connector/1.2.2.RELEASE/spring-cloud-heroku-connector-1.2.2.RELEASE.pom , ReasonPhrase:Forbidden.
    ERROR: Failed to parse POMs
    org.apache.maven.project.ProjectBuildingException: Some problems were 
    encountered while processing the POMs:
    [ERROR] Non-resolvable import POM: Could not transfer artifact 
    org.springframework.cloud:spring-cloud-heroku-connector:pom:1.2.2.RELEASE 
    from/to artifactory (http://artifactory.cos.dev:8081/artifactory/repo): Access denied to: http://artifactory.cos.dev:8081/artifactory/repo/org/springframework/cloud/spring-cloud-heroku-connector/1.2.2.RELEASE/spring-cloud-heroku-connector-1.2.2.RELEASE.pom , ReasonPhrase:Forbidden. @ line 39, column 16

at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364)
at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:361)
at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:331)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1326)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1123)
at hudson.FilePath.act(FilePath.java:998)
at hudson.FilePath.act(FilePath.java:976)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:985)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:690)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:490)
at hudson.model.Run.execute(Run.java:1735)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:415)
   Finished: FAILURE 

这是我的pom.xml

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.me.example</groupId>
  <version>1.0-SNAPSHOT</version>
  <artifactId>example</artifactId>
  <packaging>jar</packaging>

  <name>Maven Quick Start Archetype</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <dependencyManagement>
       <dependencies>           
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-heroku-connector</artifactId>
                <version>1.2.2.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>               
       </dependencies>         
    </dependencyManagement>     
</project>

如果我将依赖项从 dependencyManagement 移动到依赖项,它将正确解析。

在Jenkins-&gt;托管文件下,我的全局配置文件具有以下镜像。

<mirror>
    <id>artifactory</id>
    <mirrorOf>external:*</mirrorOf>
    <name>My Artifactory</name>
    <url>http://artifactory.cos.dev:8081/artifactory/repo</url>
</mirror> 

0 个答案:

没有答案