Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jenkins pipeline - use perform maven release button

Is there any option how to add "perform maven release" button into jenkins pipeline job. I am using option with another stage in pipeline which wait 2 minutes for user input but I don't like that every time job job waits and release is only sometimes.

Thanks.

https://i.sstatic.net/vwFF6.jpg

like image 965
stejskys Avatar asked Dec 13 '25 00:12

stejskys


1 Answers

I've he same issue... No, The M2 Release plugin only works with Maven projects, not freestyle or Pipeline, but you can use user input from pipeline to achieve the same result:

stage('release')
    {       
        def performRelease = input  message             : "Perform Maven Release?", 
                                    ok                  : "Schedule Maven Release Build", 
                                    submitter           : env.ALLOWED_SUBMITTER_RELEASE, 
                                    submitterParameter  : 'APPROVING_SUBMITTER',
                                    parameters: 
                                    [   
                                        booleanParam
                                        (
                                            defaultValue: true, 
                                            description: '',
                                            name: 'Dry run only?'
                                        ),                              
                                        string
                                        (
                                            defaultValue: '', 
                                            description: '', 
                                            name: 'Release Version'
                                        ), 
                                        string
                                        (
                                            defaultValue: '', 
                                            description: '', 
                                            name: 'Development version'
                                        )                                       
                                    ]

        if( performRelease )
        {
            dir( env.PROJECT_FOLDER ) 
            {
                withMaven(jdk:  env.JDK_VERSION , maven:  env.MVN_VERSION )
                {
                    sh "mvn ${ performRelease['Dry run only?'] ? env.MVN_RELEASE_DRYRUN_GOALS : env.MVN_RELEASE_GOALS }"        
                }
            }   
        }       
    }
like image 124
Jroger Avatar answered Dec 14 '25 20:12

Jroger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!