简体   繁体   English

从自动触发Jenkins构建中排除.yaml和.md文件

[英]Excluding .yaml and .md files from auto triggering the Jenkins build

I do not want the Jenkins build to auto trigger when .yaml files and readme files are changed and committed. 当.yaml文件和自述文件被更改和提交时,我不希望Jenkins构建自动触发。 I am looking for a global function that I can call in my Jenkinsfile. 我正在寻找一个可以在我的Jenkins文件中调用的全局函数。

Any suggestions are appreciated. 任何建议表示赞赏。

Thanks! 谢谢!

In your job's configuration under the Build Triggers section, you should be able to find what you are looking for (usually under the Advanced tab). 在“ 构建触发器”部分下的作业配置中,您应该能够找到所需内容(通常在“ 高级”选项卡下)。 For example, on my instance of Jenkins, for the "GitHub Pull Request Builder" trigger type, after clicking the Advanced button, you can see an "Excluded regions" textbox with the following help description: 例如,在我的Jenkins实例上,对于“GitHub Pull Request Builder”触发器类型,单击“ 高级”按钮后,您可以看到“排除区域”文本框,其中包含以下帮助说明:

Each exclusion uses regular expression pattern matching, and must be separated by a new line. 每个排除使用正则表达式模式匹配,并且必须用新行分隔。

  myapp/src/main/web/.*\\.html myapp/src/main/web/.*\\.jpeg myapp/src/main/web/.*\\.gif 

The example above illustrates that if only html/jpeg/gif files have been committed to the GitHub repository a build will not occur. 上面的示例说明如果只将html / jpeg / gif文件提交到GitHub存储库,则不会发生构建。 More information on regular expressions can be found here. 有关正则表达式的更多信息,请访问此处。

Other trigger types will have something similar to the notion of "Excluded regions". 其他触发类型将具有类似于“排除区域”的概念。

Moreover, Jenkins has added functionality like this in various ways as discussed in resolved Jira tickets such as JENKINS-21418 and JENKINS-36614 . 此外,Jenkins已经以各种方式添加了这样的功能,如JENKINS-21418JENKINS-36614等已解决的Jira门票中所述。

I hope that helps. 我希望有所帮助。 I know that it isn't a global function in a Jenkins file, as per the question, but I think that it can be a viable solution to the problem in general. 据我所知,我知道它不是Jenkins文件中的全局函数,但我认为它通常可以解决这个问题。

Jenkins declarative language checkout presumably also cover excludedRegions which is the same option @entpnerd described in the GitHub Pull Request Builder plugin: Jenkins声明性语言检查可能还包括excludedRegions ,它与GitHub Pull Request Builder插件中描述的@entpnerd相同:

excludedRegions excludedRegions

If set, and Jenkins is set to poll for changes, Jenkins will ignore any files and/or folders in this list when determining if a build needs to be triggered. 如果设置,并且Jenkins设置为轮询更改,Jenkins将在确定是否需要触发构建时忽略此列表中的所有文件和/或文件夹。

See a Jenkinsfile example in a similar stackoverflow question . 类似的stackoverflow问题中查看Jenkinsfile示例。 Jira issue JENKINS-36195 requested for this functionality and JENKINS-36836 provided working and not working cases and why. Jira问题JENKINS-36195要求此功能, JENKINS-36836提供工作而非工作案例及其原因。

The reality is that it is not working and it is not planned to be included : 现实情况是它不起作用,并没有计划包括在内

There have been some brief discussions about it, but there are no plans to address it 有一些关于它的简短讨论,但没有计划解决它

so I would go for Jenkins GUI polling configuration. 所以我会去Jenkins GUI轮询配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM