Home > Software design >  Jenkins and Maven - empty package - how to define what should be packaged?
Jenkins and Maven - empty package - how to define what should be packaged?

Time:07-27

I defined a Jenkins job to build my code. I get an JAR output but with empty content. How I should define what folder should be pakcaged? Code which I got from developers is mostly AngularJS scripts along with some npm packages which are being installed and used for npm build. After that I need to create maven package and upload it to JFROG Artifactory. After the npm install and npm build I am getting new folder dist and its subfolder arena-web-ruf needs to be packaged as a result of Jenkins build.

So the folder that needs to be packaged from the current folder where Jenkins is triggered is: ./dist/apps/arena-web-ruf/ How does maven knows that it should pick that folder? I tried to zip manually that folder and unzip it in the current dir with same name arena-web-ruf but I got empty JAR.

pom.xml definition:

<modelVersion>4.0.0</modelVersion>
<groupId>iprods</groupId>
<artifactId>arena-web-ruf</artifactId>
<version>2022.3-SNAPSHOT</version>

Jenkins build definition:

        steps {
            rtServer (
                id: 'Artifactory',
                url: 'https://artifactory.domain.dev/artifactory',
                credentialsId: 'ac0c0e829676'
            )

            rtMavenDeployer (
            id: "MAVEN_DEPLOYER",
            serverId: "Artifactory",
            releaseRepo: "my-generic-release-local",
            snapshotRepo: "my-generic-snapshot-local"
            )

            rtMavenResolver (
                id: "MAVEN_RESOLVER",
                serverId: "Artifactory",
                releaseRepo: "apache-maven-remote",
                snapshotRepo: "apache-maven-remote"
            )
        }

............................................................

        steps {
            rtMavenRun (
                tool: "maven-3.2.5", // Tool name from Jenkins configuration
                pom: 'pom.xml',
                goals: 'clean install',
                deployerId: "MAVEN_DEPLOYER",
                resolverId: "MAVEN_RESOLVER"
            )
        }

Relevant logs:

  ls -ltr
> .............
> -rw-rw-r--   1 jenkins jenkins    4239 Jul 25 06:47 Jenkinsfile
> -rw-rw-r--   1 jenkins jenkins     415 Jul 25 06:47 pom.xml .......................
> -rw-rw-r--   1 jenkins jenkins   11155 Jul 25 06:50 arena-web-ruf-qa-2022-07-49.zip 
> drwxrwxr-x   3 jenkins jenkins    8192 Jul 25 06:50 arena-web-ruf
[main] WARN org.apache.maven.plugin.jar.JarMojo - JAR will be empty - no content was marked for inclusion!
[main] INFO org.codehaus.plexus.archiver.jar.JarArchiver - Building jar: /data/jenkins/maven/target/arena-web-ruf-2022.3-SNAPSHOT.jar
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - 
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-install-plugin:2.4:install (default-install) @ arena-web-ruf ---
[main] INFO org.apache.maven.DefaultMaven - Installing /data/jenkins/maven/target/arena-web-ruf-2022.3-SNAPSHOT.jar to /home/jenkins/.m2/repository/iprods/arena-web-ruf/2022.3-SNAPSHOT/arena-web-ruf-2022.3-SNAPSHOT.jar
[main] INFO org.apache.maven.DefaultMaven - Installing /data/jenkins/maven/pom.xml to /home/jenkins/.m2/repository/iprods/arena-web-ruf/2022.3-SNAPSHOT/arena-web-ruf-2022.3-SNAPSHOT.pom
[main] INFO org.jfrog.build.extractor.maven.BuildDeploymentHelper - Artifactory Build Info Recorder: Saving Build Info to '/data/jenkins/maven/target/build-info.json'
[pool-6-thread-1] INFO org.jfrog.build.extractor.maven.BuildInfoClientBuilder - [pool-6-thread-1] Deploying artifact: https://artifactory.domain.dev/artifactory/my-generic-snapshot-local/iprods/arena-web-ruf/2022.3-SNAPSHOT/arena-web-ruf-2022.3-SNAPSHOT.jar
[pool-6-thread-1] INFO org.jfrog.build.extractor.maven.BuildInfoClientBuilder - [pool-6-thread-1] Deploying artifact: https://artifactory.domain.dev/artifactory/my-generic-snapshot-local/iprods/arena-web-ruf/2022.3-SNAPSHOT/arena-web-ruf-2022.3-SNAPSHOT.pom
[main] INFO org.jfrog.build.extractor.maven.BuildDeploymentHelper - Artifactory Build Info Recorder: publish build info set to false, build info will not be published...
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD SUCCESS

CodePudding user response:

As discussed in the chat, and assuming you have a pom file to upload alongside the zip, you can do something like this:

spec: """{
    "files": [
        {
            "pattern": "arena-web/arena.zip",
            "target": "myrepo/the/group/arena-web/1.0.0-SNAPSHOT/arena-web-1.0.0-SNAPSHOT.zip"
        },
        {
            "pattern": "wherever/is/pom.xml",
            "target": "myrepo/the/group/arena-web/1.0.0-SNAPSHOT/arena-web-1.0.0-SNAPSHOT.pom"
        }
    ]
}"""
  • Related