Jenkins Pipeline - 使用执行Maven发布按钮。

3

有没有办法在Jenkins管道作业中添加“执行Maven发布”按钮的选项。我正在使用另一个阶段的选项,在管道中等待2分钟以等待用户输入,但我不喜欢每次作业等待,而发布只是偶尔进行的。

谢谢。

https://istack.dev59.com/vwFF6.webp


你想添加哪个步骤以及在哪里? - Naman
当我在配置Maven项目时,我可以配置Maven发布选项,然后在作业左侧面板上有Maven发布按钮。但是,当我使用Pipeline项目时,我无法这样做。所以我想在Pipeline项目中添加此按钮。这是否可能?感谢您的答复。PS. 我在问题中添加了Maven项目左侧面板的屏幕截图。 - stejskys
1个回答

5

我遇到了同样的问题...不,M2 Release插件只适用于Maven项目,而不是自由风格或Pipeline,但您可以在Pipeline中使用用户输入来实现相同的效果:

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 }"        
                }
            }   
        }       
    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接