mohitmayank
mohitmayank

Reputation: 661

Gradle release plugin with Jenkins not pushing release builds

I'm trying to use gradle-release plugin while using Jenkins for CI. Two commits are created on doing a release using:

gradle release -PuseAutomaticVersion=true

A pre-tag commit with say version=0.0.4 and another with version=0.0.5-SNAPSHOT. The problem is that Jenkins only picks up the latest commit since they happen one after another. Due to this the release build is never deployed to the Nexus.

Notice the tick on only the top commit:enter image description here

Upvotes: 1

Views: 1884

Answers (1)

Cisco
Cisco

Reputation: 22952

My understanding of the green check mark is just a visual indicator that that commit did not break the build.

Uploading your artifact isn't something Jenkins handles per se, you need to configure the release plugin to invoke your Gradle publishing task as documented in the readme here.

So for example, using the recommended Maven Publish plugin, you Gradle build file may look like:

plugins {
    id "java"
    id "maven-publish"
    id "net.researchgate.release" version "2.8.1"
}

publishing {
    repositories {
        maven {
            url = "https://your-company-nexus-repo.com/repositories"
        }
    }
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
}

tasks {
    afterReleaseBuild {
        dependsOn publish
    }
}

Upvotes: 2

Related Questions