Gradle + Jenkins + Artifactory Maven Repo?

user2684301 picture user2684301 · Mar 16, 2014 · Viewed 8.2k times · Source

I have a Java project, building with Gradle, using the Jenkins CI server, and I would like to publish to an Artifactory server, using Maven-compatible artifacts. The project is using Git. I would also like to use the release management features of Jenkins if possible.

This is very confusing. There are at least five plugins, with much overlapping redundant functionality. Some plugins seem to replace others. Some plugins seem to require others.

FYI, the five relevant plugins seem to be:

1) Jenkins Artifactory Plugin https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin

2) Gradle "maven" Plugin http://www.gradle.org/docs/current/userguide/maven_plugin.html

3) Gradle "maven-publish" Plugin http://www.gradle.org/docs/current/userguide/publishing_maven.html

4) Gradle "artifactory" Plugin https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin

5) Gradle "artifactory-publish" Plugin http://www.jfrog.com/confluence/display/RTF/Gradle+1.6+Publishing+Artifactory+Plugin

What is the best way to set this up?

If I use the Jenkins Artifactory Plugin with none of the other plugins mentioned, I get an error:

No publish configurations specified for project ':' and the default 'archives' configuration does not exist.
Cannot publish pom for project ':my-great-app' since it does not contain the Maven plugin install task and task ':my-great-app:artifactoryPublish' does not specify a custom pom path.

I assume I need to use either maven or maven-publish in build.gradle?

maven-publish is labeled as the incubating successor to the maven plugin. How much better is it? How stable is it?

How does using one of the Gradle Artifactory plugins compare to the standard maven publishing plugins vs using the Jenkins plugin?

Answer

JBaruch picture JBaruch · Mar 16, 2014
  • Gradle Artifactory plugins: Gradle can deploy build artifacts and build information directly, without need in CI server by using one of the Artifactory plugins.
    • artifactory plugin works with maven plugin and publishes configurations, generated by maven plugin.
    • artifactory-publish plugin works with maven-publish plugin and publishes publications generated by maven-publish plugin.
  • Jenkins Artifactory plugin works in two modes:
    • Providing a UI to override settings, specified in artifactory or artifactory-publish plugins in Gradle build script.
    • Adding and configuring artifactory plugin to the Gradle script if it is not there.
    • It also provides release management (for both modes).

So, here's what you need to decide:

  • Whether you use one of the Gradle plugins. Our recommendation is - use it (versioned configuration in build script is an advantage comparing to UI-only configuration.
  • Which plugin you want to use -- maven or maven-publish. While the later is still 'incubating', it is much more flexible than the former. Once you know with which maven plugin you want to use, select the appropriate artifactory plugin.
  • You need the Artifactory Jenkins plugin in either way if you want to use the release functionality, just check (or uncheck) the 'Project uses the Artifactory Gradle Plugin' checkbox.