2014-09-02 17 views
0

我有一個在本地機器上正確構建的項目。在我的公司,我們使用服務器機器進行持續集成,但該機器無法連接到互聯網。所以我設置了artifactory並將我的整個存儲庫複製到它。然後連接jenkins與這個artifactory。所以詹金斯應該做沒有任何問題的建設沒有?因爲它與我的本地項目具有相同的設置。Maven根據運行哪臺機器使用不同的依賴關係?

建立消息的幾秒鐘後彈出,他無法找到一個依賴:

[錯誤]未能就項目的CRS-數據執行目標:無法解析 依賴項目COM .ing.crs:crs-data:jar:1.1.3-SNAPSHOT: 無法收集 的依賴關係[com.ing.crs:crs-framework:jar:1.1.3-SNAPSHOT(compile), org.apache .openjpa:openjpa-all:jar:2.3.0(提供), ibm.websphere:j2ee6:jar:8.5.0(提供), ibm.websphere:jpaThinClient:jar:8.5.0(提供), com .google.guava:合谷ava:jar:14.0.1(compile), org.hamcrest:hamcrest-all:jar:1.3(test),junit:junit:jar:4.11(test), mockito-all:mockito-all:jar:1.8 .4(test),oracle.jdbc:ojdbc6:jar:11.2 (test),com.h2database:h2:jar:1.3.167(test), ibm.websphere:embeddedEJBContainer:jar:8.5.0(test) , com.ing.be:bbllib.DeploymentInfo:jar:2.3.2(provided)]:未能通過 讀取commons-dbcp的工件描述符:commons-dbcp:jar:1.4:可能 不能傳遞工件commons-dbcp :公地DBCP:POM:1.4自/至 crs.maven.repo (http://sdbeapp00433.devbe.development:8082/artifactory/repo):訪問 拒絕: http://sdbeapp00433.devbe.development:8082/artifactory/repo/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.pom - > [Help 1]

但是本地編譯甚至不使用commons-dbcp:commons-dbcp:pom:1.4。這怎麼可能?

的POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<parent> 
    <groupId>com.ing.crs</groupId> 
    <artifactId>crs-parent-pom</artifactId> 
    <version>1.1.3-SNAPSHOT</version> 
    <relativePath>../crs-parent-pom/pom.xml</relativePath> 
</parent> 
<modelVersion>4.0.0</modelVersion> 
<artifactId>crs-data</artifactId> 
<version>${project.crs-data.version}</version> 

<profiles> 
    <profile> 
     <id>default</id> 
     <properties> 
      <dbDictionary>disableAlterSeqenceIncrementBy=true</dbDictionary> 
     </properties> 
    </profile> 
    <profile> 
     <id>stubs</id> 
     <properties> 
      <dbDictionary></dbDictionary> 
     </properties> 
    </profile> 
</profiles> 

<dependencies> 
    <!-- CRS --> 
    <dependency> 
     <groupId>com.ing.crs</groupId> 
     <artifactId>crs-framework</artifactId> 
     <version>${project.crs-framework.version}</version> 
    </dependency> 

    <!-- Other --> 
    <dependency> 
     <groupId>org.apache.openjpa</groupId> 
     <artifactId>openjpa-all</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>ibm.websphere</groupId> 
     <artifactId>j2ee6</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>ibm.websphere</groupId> 
     <artifactId>jpaThinClient</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
    </dependency> 

    <!-- test --> 
    <dependency> 
     <groupId>org.hamcrest</groupId> 
     <artifactId>hamcrest-all</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>mockito-all</groupId> 
     <artifactId>mockito-all</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>oracle.jdbc</groupId> 
     <artifactId>ojdbc6</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.h2database</groupId> 
     <artifactId>h2</artifactId> 
     <version>1.3.167</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>ibm.websphere</groupId> 
     <artifactId>embeddedEJBContainer</artifactId> 
     <version>8.5.0</version> 
     <scope>test</scope> 
    </dependency>   
    <dependency> 
     <groupId>com.ing.be</groupId> 
     <artifactId>bbllib.DeploymentInfo</artifactId> 
     <scope>provided</scope> 
    </dependency> 
</dependencies> 

<build> 
    <finalName>crs-data</finalName> 
    <outputDirectory>target/crs-data</outputDirectory> 
    <plugins>   
     <plugin> 
      <groupId>org.bsc.maven</groupId> 
      <artifactId>maven-processor-plugin</artifactId> 
      <version>2.2.4</version> 
      <executions> 
       <execution> 
        <id>process</id> 
        <goals> 
         <goal>process</goal> 
        </goals> 
        <phase>generate-sources</phase> 
        <configuration> 
         <compilerArguments>-Aopenjpa.source=7 -Aopenjpa.metamodel=true</compilerArguments> 
         <processors> 
          <processor>org.apache.openjpa.persistence.meta.AnnotationProcessor6</processor> 
         </processors> 
         <outputDirectory>target/generated-sources/metamodel</outputDirectory> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>build-helper-maven-plugin</artifactId> 
      <version>1.8</version> 
      <executions> 
       <execution> 
        <id>add-source</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>add-source</goal> 
        </goals> 
        <configuration> 
         <sources> 
          <source>target/generated-sources/metamodel</source> 
         </sources> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ejb-plugin</artifactId> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.openjpa</groupId> 
      <artifactId>openjpa-maven-plugin</artifactId> 
      <version>2.3.0</version> 
      <executions> 
       <execution> 
        <id>enhancer_for_test</id> 
        <configuration> 
         <includes>**/entities/**/*.class</includes> 
         <includes>**/data/**/*.class</includes> 
         <addDefaultConstructor>true</addDefaultConstructor> 
         <enforcePropertyRestrictions>true</enforcePropertyRestrictions> 
        </configuration> 
        <phase>compile</phase> 
        <goals> 
         <goal>enhance</goal> 
        </goals> 
       </execution> 
      </executions> 
      <dependencies> 
       <dependency> 
        <groupId>org.apache.openjpa</groupId> 
        <artifactId>openjpa</artifactId> 
        <version>2.3.0</version> 
       </dependency> 
      </dependencies> 
     </plugin>       
    </plugins> 

    <pluginManagement> 

     <plugins> 
      <plugin> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <version>1.3</version> 
       <executions> 
        <execution> 
         <id>copy-test-persistence</id> 
         <phase>process-test-resources</phase> 
         <configuration> 
          <tasks> 
           <!--backup the "proper" persistence.xml--> 
           <copy file="${project.build.outputDirectory}/META-INF/persistence.xml" tofile="${project.build.outputDirectory}/META-INF/persistence.xml.proper"/> 
           <!--replace the "proper" persistence.xml with the "test" version--> 
           <!-- copy file="${project.build.testOutputDirectory}/META-INF/persistence.xml" tofile="${project.build.outputDirectory}/META-INF/persistence.xml"/--> 
          </tasks> 
         </configuration> 
         <goals> 
          <goal>run</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>restore-persistence</id> 
         <phase>prepare-package</phase> 
         <configuration> 
          <tasks> 
           <!--restore the "proper" persistence.xml--> 
           <copy file="${project.build.outputDirectory}/META-INF/persistence.xml.proper" tofile="${project.build.outputDirectory}/META-INF/persistence.xml"/> 
          </tasks> 
         </configuration> 
         <goals> 
          <goal>run</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin>   

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-jar-plugin</artifactId> 
       <configuration> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <classpathLayoutType>custom</classpathLayoutType> 
          <customClasspathLayout>${artifact.artifactId}.${artifact.extension}</customClasspathLayout> 
         </manifest> 
         <manifestEntries> 
          <Implementation-Version>${project.version}</Implementation-Version> 
          <Build-Time>${timestamp}</Build-Time> 
         </manifestEntries> 
        </archive> 
       </configuration> 
      </plugin> 
      <!--This plugin's configuration is used to store Eclipse m2e settings 
      only. It has no influence on the Maven build itself. --> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.1.1</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId> 
             org.codehaus.mojo 
            </groupId> 
            <artifactId> 
             openjpa-maven-plugin 
            </artifactId> 
            <versionRange> 
             [1.0,) 
            </versionRange> 
            <goals> 
             <goal>enhance</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <execute> 
             <runOnIncremental>false</runOnIncremental> 
            </execute> 
           </action> 
          </pluginExecution> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId> 
             org.apache.openjpa 
            </groupId> 
            <artifactId> 
             openjpa-maven-plugin 
            </artifactId> 
            <versionRange> 
             [2.2.1,) 
            </versionRange> 
            <goals> 
             <goal>enhance</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <ignore /> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
    <resources> 
     <resource> 
      <directory>src/main/resources/</directory> 
      <filtering>true</filtering> 
     </resource> 
    </resources> 
</build> 

+0

你可以給我們一些其他關於這個的信息嗎?應該建立沒有任何問題沒有?**你在建什麼(除了共享你的pom.xml)? – Skizzo 2014-09-02 12:23:08

+0

這裏是pom – Juru 2014-09-02 13:20:25

+0

commons-dbcp可以被你的一個依賴/插件使用。將〜/ .m2複製到〜/ jenkins/.m2並重試。第二個解決方案是在artifactory中配置代理和外部存儲庫。 – 2014-09-02 13:26:25

回答

1

你的構建是失敗的,因爲Maven是無法下載從Artifactory的依賴性因認證問題:

Access denied to: http://sdbeapp00433.devbe.development:8082/artifactory/repo/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.pom 

如果你會看Artifactory access.log您應該看到一個關於拒絕下載的匹配日誌條目。

如果您使用的是Artifactory Jenkins插件,則可以按照here中所述配置解析器憑據。
如果您未使用Artifactory Jenkins插件,則應按照"Working With Maven"中所述配置Maven認證。這需要向Maven settings.xml文件添加正確的憑據。
第三個選項是允許匿名訪問Artifactory,如here所述。這將允許解決來自Artifactory的依賴關係而無需身份驗證。

commons-dbcp可能是傳遞性依賴。如果你想找到它的起源,你應該使用Maven依賴項插件的dependency:tree目標,它顯示了這個項目的依賴關係樹。

作爲一個方面說明,你不應該使用「回購」存儲庫。這是一個默認的全局虛擬存儲庫,可有效地聚合所有其他存儲庫。通過使用此URL配置Maven,任何對工件的請求都將通過Artifactory,它將搜索系統中定義的所有本地和遠程存儲庫。最好使用一個虛擬存儲庫,它只爲您的構建彙集相關的存儲庫。

+0

artifactory沒有驗證錯誤。它說因爲它找不到它試圖打開的pom。但問題是爲什麼當我在本地構建時不需要使用該文件。 因此,當我在本地構建vs通過jenkins構建時,會出現不同的構建行爲。 – Juru 2014-09-03 13:43:17

+0

嘗試使用dependency:tree來查找commons-dbcp依賴項的來源。在Jenkins的構建環境和本地構建環境之間是否存在差異:Maven版本,正在使用Maven配置文件?你是否嘗試使用乾淨的Maven緩存(本地存儲庫)在本地構建?另外,您是否嘗試從Artifactory下載commons-dbcp依賴項? – 2014-09-03 13:52:47