Home » Android » android – No artifacts found that match the file pattern "**/target/*.apk"

android – No artifacts found that match the file pattern "**/target/*.apk"

Posted by: admin June 15, 2020 Leave a comment

Questions:

I got this output from Jenkins console while trying to compile an android project:
just notice that I didn’t make any change on the main Class
this is the jenkins console:

[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

and this is my 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>

I think my problem come from target directory because jenkins mentioned that.
I had 3 directories at jenkins: assets ,res et src
Should I add more then these three folders? for example libs or target ??

How to&Answers:

The Archive Artifacts post-build step does not care about your POM. All it does is look for files in your workspace folder, i.e $WORKSPACE (also accessible through http://[jenkins-url]/job/[job-name]/ws ) and archives those within Jenkin’s build history.

The files that you are trying to archive must exist in the $WORKSPACE. From your configuration, you are trying to archive **/target/*.apk which means “under any path, folder target with any file and extension .apk. It can’t find that, since your workspace doesn’t have folder target anywhere, hence the ERROR: ‘**/target/*.apk’ doesn’t match anything: ‘**’ exists but not ‘**/target/*.apk’

In your POM file, you have the following line:
<directory>${project.basedir}/assets/build</directory>
This is what identifies where your built files end up. It is [base-dir-of-pom]/assets/build, not target.

Also, form your console log:
[JENKINS] Archiving /var/opt/jenkins/workspace/Android-Project-App/trunk/assets/build/project-android.apk
Which further proves that your .apk artifact is in fact located under trunk/assets/build

For your Archive Artifacts file pattern, you need to use:
**/assets/build/*.apk

And as a matter of fact, you could use just:
**/build/*.apk or even
**/*.apk

But the question is: do you really want to be archiving the artifacts on Jenkins (which takes space) when you are already archiving the artifacts with Maven?

Answer:

I wanted to archive release.apk, and I ran into the same trouble as you. Jenkins prompts me should do like: app/build/outputs/apk/yourAppName/release/*.apk, and it fixed my problem.

Jenkins job config snapshort