Jenkins Artifactory plugin not generating POM file Jenkins Artifactory plugin not generating POM file jenkins jenkins

Jenkins Artifactory plugin not generating POM file


A Maven repository indeed provides artefacts (normally jar files) and pom files (.pom extension) listing the required dependencies and their scope (so that they can transitively resolved to recreate the whole required dependency graph per each artefact). So indeed you would need the jar and the .pom file.

I had exactly the same issue but for a maven build. In my case the Jenkins build was executing the mvn clean package command, which effectively creates the desired jar file. Then the Artifactory Jenkins Plugin was correctly pushing the jar to Artifactory, perfectly available with the desired Maven coordinates (GAV, groupId, artifactId, version). However, the .pom file was missing.
In my case, solution was to change the invoked Maven phase, from package to install. The install phase indeed creates also the desired .pom file and additionally installs the artefact on the local repository (the Maven cache).

So, simply switching to mvn clean install, the Artifactory Jenkins Plugin was correctly uploading .jar and .pom file.

In your case, for a gradle build the issue could potentially be the same. You are probably creating the expected jar file and the Artifactory Jenkins Plugin is correctly picking it up and pushing it to Artifactory, but no .pom file is generated and as such not uploaded. So, if you are invoking gradle assemble or gradle build you are correctly generating the jar, but not the .pom file. You should probably also execute on the Jenkins build a gradle install command using the maven plugin as explained in this other SO answer and by the plugin documentation, from which we can also read:

31.6.3. Installing to the local repository
The Maven plugin adds an install task to your project. This task depends on all the archives task of the archives configuration. It installs those archives to your local Maven repository.

31.6.4. Maven POM generation
When deploying an artifact to a Maven repository, Gradle automatically generates a POM for it.

Beware though that "While the maven plugin does provide the install task, it only adds the task in the presence of the java plugin". Alternatively, to create the .pom file, you could also consider the maven-publish plugin and its publishToMavenLocal task.

So, to summarize: to properly create .jar and .pom file, you need to install the artefact on the local cache (in your case: the local cache of the Jenkins server, an harmless action), because as part of this process the required files are created as output of the build. The Artifactory Jenkins Plugin will then pick them up and properly upload them.

Update
Alternatively and as described in the comments below (and in another SO question), you could also avoid the install step and rather add a createPom task to your gradle build, in order to create the POM file as following:

task createPom << {     pom {         project {             groupId 'company'            artifactId project.name            version "$version"        }    }.writeTo("pom.xml")}


What helped me was adding the following configuration:

Include Patterns: *.pom *.jar

There also should be enabled maven plugin in build.gradle:

apply plugin: 'maven-publish'

After that generated pom and artifacts were successfully uploaded by Jenkins job to Artifactory.Make sure that Publish Maven descriptors flag is set to true.