找不到与文件模式“** / target / * .apk”匹配的工件

时间:2014-05-29 16:35:52

标签: android maven jenkins

我在尝试编译android项目时从Jenkins控制台获得了这个输出: 请注意,我没有对主类进行任何更改 这是jenkins控制台:

[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.701s
[INFO] Finished at: Thu May 29 17:56:45 CEST 2014
[INFO] Final Memory: 24M/491M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /var/opt/jenkins/workspace/Android-Project-App/trunk/pom.xml to com.proj.android.project.mobile/project-android/0.0.1-SNAPSHOT/project-android-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /var/opt/jenkins/workspace/Android-Project-App/trunk/assets/build/project-android.apk to com.proj.android.project.mobile/project-android/0.0.1-20140529.155643-5/project-android-0.0.1-20140529.155643-5.apk
[JENKINS] Archiving /var/opt/jenkins/workspace/Android-Project-App/trunk/assets/build/project-android.jar to com.proj.android.project.mobile/project-android/0.0.1-20140529.155643-5/project-android-0.0.1-20140529.155643-5.jar
channel stopped
Archiving artifacts
ERROR: No artifacts found that match the file pattern "**/target/*.apk". Configuration error?
ERROR: ‘**/target/*.apk’ doesn’t match anything: ‘**’ exists but not ‘**/target/*.apk’
Build step 'Archive the artifacts' changed build result to FAILURE
IRC notifier plugin: Sending notification to: #jenkins
Finished: FAILURE

这是我的pom:

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.proj</groupId>
        <artifactId>android</artifactId>
        <version>1.1-SNAPSHOT</version>
    </parent>

    <groupId>com.proj.android.project.mobile</groupId>
    <artifactId>project-android</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>project Android Application</name>
    <description>project mobile application for android client</description>
    <url>http://maven.apache.org</url>

    <issueManagement>
        <system>jira</system>
        <url>http://www/jira/browse/${jira.project.key}</url>
    </issueManagement>
    <scm>
        <connection>scm:svn:http://svn/android/project-mobile-app/trunk/</connection>
        <developerConnection>scm:svn:https://svn/android/project-mobile-app/trunk/</developerConnection>
        <url>http://svn/web/wsvn/android/project-mobile-app/</url>
    </scm>
    <dependencyManagement>
        <dependencies>
            <!-- Android dependencies -->
            <dependency>
                <groupId>android</groupId>
                <artifactId>android</artifactId>
                <scope>provided</scope>
                <version>4.0.3_r2</version>
            </dependency>
            <dependency>
                <groupId>android</groupId>
                <artifactId>support-v4</artifactId>
                <version>r6</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <scope>test</scope>
                <version>${junit.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-plugin-api</artifactId>
                <version>3.1</version>
            </dependency>
            <dependency>
                <groupId>bouncycastle</groupId>
                <artifactId>bcprov-jdk14</artifactId>
                <version>138</version>
            </dependency>
            <!-- <dependency> -->
            <!-- <groupId>com.proj.android.sample</groupId> -->
            <!-- <artifactId>pdf-viewer-ng</artifactId> -->
            <!-- <type>apklib</type> -->
            <!-- <version>1.0-SNAPSHOT</version> -->
            <!-- </dependency> -->
            <dependency>
                <groupId>com.proj.project.client</groupId>
                <artifactId>project-client</artifactId>
                <version>${project-client.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>build</sourceDirectory>
        <directory>${project.basedir}/assets/build</directory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <extractDuplicates>true</extractDuplicates>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>
    <properties>
        <android.version>4.0.3_r2</android.version>
        <android.sdk>15</android.sdk>
        <android.emulator.avd>AVD_15_4_0_3</android.emulator.avd>
        <jira.project.key>UNIAPPAND-1</jira.project.key>
        <junit.version>4.11</junit.version>
        <com.proj.project.client>1.0-SNAPSHOT</com.proj.project.client>
    </properties>
</project>

我认为我的问题来自目标目录,因为詹金斯提到了这一点。 我在jenkins有3个目录:assets,res et src 我应该添加更多这三个文件夹吗?例如libs或target ??

2 个答案:

答案 0 :(得分:8)

存档工件构建后步骤并不关心您的POM。它只是查找工作区文件夹中的文件,即$WORKSPACE(也可通过http://[jenkins-url]/job/[job-name]/ws访问)并将这些文件存档在Jenkin的构建历史记录中。

您尝试归档的文件必须存在于$WORKSPACE中。在您的配置中,您尝试归档**/target/*.apk,这意味着“在任何路径下,文件夹target包含任何文件和扩展名.apk。它无法找到,因为您的工作区在任何地方都没有文件夹target,因此ERROR: ‘**/target/*.apk’ doesn’t match anything: ‘**’ exists but not ‘**/target/*.apk’

在您的POM文件中,您有以下行: <directory>${project.basedir}/assets/build</directory>
这标识了构建文件的最终位置。它是[base-dir-of-pom]/assets/build,而不是target

另外,形成您的控制台日志:
[JENKINS] Archiving /var/opt/jenkins/workspace/Android-Project-App/trunk/assets/build/project-android.apk
这进一步证明您的.apk工件实际上位于trunk/assets/build

对于存档工件文件模式,您需要使用:
**/assets/build/*.apk

事实上,你可以只使用:
**/build/*.apk甚至是 **/*.apk

但问题是:当你已经使用Maven存档工件时,你真的想要在Jenkins上存档工件(这会占用空间吗?)

答案 1 :(得分:0)

我想存档release.apk,因此遇到了与您相同的麻烦。 Jenkins提示我应该这样做:app / build / outputs / apk / yourAppName / release / *。apk,它解决了我的问题。

Jenkins job config snapshort