【发布时间】:2015-02-16 15:44:54
【问题描述】:
我正在考虑在 Jenkins 中为我的构建作业使用 Groovy 脚本,因为我有一些条件要检查,可能需要访问 Jenkins API。
是否可以通过 Groovy 脚本找出是谁或什么触发了构建? SCM 更改、另一个项目或用户。我刚刚开始阅读一些关于 Groovy 和 Jenkins API 的内容。
我想检查以下条件并相应地构建。一些伪代码:
def buildTrigger JenkinsAPI.thisBuild.Trigger
if (buildTrigger == scm) {
execute build_with_automake
def new_version = check_git_and_look_up_tag_for_version
if (new_version) {
execute git tag new_release_candidate
publish release_candidate
}
} else if (buildTrigger == "Build other projects") {
execute build_with_automake
}
项目应该建立在每个 SCM 更改的基础上,但只有在版本增加时才标记和发布。当构建被另一个项目触发时,它也应该构建。
【问题讨论】:
标签: groovy jenkins jenkins-scriptler