Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle + Jenkins + Artifactory Maven Repo?

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?

like image 895
user2684301 Avatar asked Mar 16 '14 05:03

user2684301


People also ask

Is Artifactory a Maven repository?

As a Maven repository, Artifactory is both a source for artifacts needed for a build, and a target to deploy artifacts generated in the build process. Maven is configured using a settings. xml file located under your Maven home directory (typically, this will be /user.

What is Artifactory gradle?

The Gradle Artifactory Plugin allows you to deploy your build artifacts and build information to Artifactory and also to resolve your build dependencies from Artifactory. The minimum supported Gradle version is 4.10.

How do you deploy artifacts from Jenkins to Artifactory?

This is made via passing Jenkins BUILD_NUMBER variable to Maven. In the post-build actions section, add deploy artifacts to the Artifactory step, specify that you would like to add your artifacts, and check the 'Deploy Maven Artifacts' checkbox. You will also need to specify a project name and path to your repository.


1 Answers

  • 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.
like image 173
JBaruch Avatar answered Oct 19 '22 08:10

JBaruch