manzk
manzk

Reputation: 666

How to perform a maven release from Jenkinsfile?

How can I perform a maven release from the Jenkins file in my program? I used to have a button in Jenkins which did the maven release from me. Now I am working on Jenkins which is operated through a Jenkinsfile and the button isn't there anymore. I was wondering if there is some configuration I could do on Jenkins in order to do the release. My Jenkins file currently looks like this:

    stage('Checkout') {
        scmCheckout {
            deleteWorkspace = 'true'
            maven_version = 'maven 3.6'
        }
    }

    stage('Build') {
        javaCompile {
            goals = "clean install"
        }
    }


stage("Release") {
    //I want to do the release here somehow
}

Upvotes: 1

Views: 409

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35863

Ok, you want to use the maven release plugin (would have been good to mention that in the question). You can call it from a Jenkinsfile just like any other Maven phase or goal. So insteal of mvn clean install you can also call mvn release:prepare releaes:perform with the appropriate parameters.

Upvotes: 1

Related Questions