Jenkins管道,Bitbucket挂钩和Maven发布插件无限循环 [英] Jenkins pipeline, bitbucket hook and maven release plugin infinite loop

查看:255
本文介绍了Jenkins管道,Bitbucket挂钩和Maven发布插件无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到有关此的任何信息,所以我希望你们能在这一方面为我提供帮助

I haven't been able to find any info about this, so i hope you guys can help me on this one

我在bitbucket中托管了一个Maven项目,该项目的BitBucket WebHook指向someurl/bitbucket-hook/,该钩子触发了我的项目的构建,该项目由具有以下结构的管道定义:

I've a maven project hosted in bitbucket that has a BitBucket WebHook pointing to someurl/bitbucket-hook/ , this hooks triggers the build of my project that is defined by a pipeline that has this structure:

node {
   stage 'Checkout'
   git url: 'https:...'

   def mvnHome = tool 'M3'

   #Various stages here
   ...
   stage 'Release'
   sh "${mvnHome}/bin/mvn -B clean install release:prepare release:perform release:clean"
}

问题是Maven发行插件将更改推送到BitBucket,这又触发了jenkins脚本,使构建过程无限循环,是否有办法防止这种情况发生?

the problem is that maven release plugin pushes changes to BitBucket, and this triggers again the jenkins script, making an infinite loop of builds, is there a way to prevent this?

我尝试在詹金斯(Jenkins)设置一个安静的时期,但没有成功

I've tried setting a quiet period in Jenkins with no success

推荐答案

从我的角度来看,您应该具有用于​​构建和发布的特定作业,并且应手动触发发布作业.无论如何,如果出于某些原因让他们参加工作,则可以检查上一次提交的消息:

From my perspective you should have specific jobs for build and release, and the release job should be triggered manually. Anyway, if there is some reason to have them in the job you can check for the message of the last commit:

node {
  git 'https...'
  sh 'git log -1 > GIT_LOG'
  git_log = readFile 'GIT_LOG'
  if (git_log.contains('[maven-release-plugin]')) {
    currentBuild.result = 'ABORTED'
    return
  }
  ... // continue with release or whatever

}

这篇关于Jenkins管道,Bitbucket挂钩和Maven发布插件无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆