obe*_*ies 34
通过以下配置,您可以创建作业构建所有标记:
+refs/tags/*:refs/remotes/origin/tags/**/tags/*这种方法有一个缺点:作业将构建所有标签而不仅仅是新添加的标签.因此,在创建作业后,将为每个现有标记触发一次.因此,您可能希望一开始就不执行任务,然后等待所有现有标记都已处理完毕,然后再配置要为每个新标记完成的构建步骤.
由于标签在git中没有变化,因此每个新标签只会触发一次作业.
ssc*_*rth 17
为了克服@oberlies回答所有标签将被构建的缺点,我正在使用特殊的触发器构建.触发器构建使用与主构建和以下(post)构建步骤相同的git存储库和分支.
构建 - >执行shell:
# Get the most recent release tag.
PATTERN="release-tag-[0-9][0-9]-[0-9][0-9][0-9][0-9]"
TAG=$(git log --tags=$PATTERN --no-walk --pretty="format:%d" | grep -m 1 -o $PATTERN)
# Due to a Jenkins limitation (https://issues.jenkins-ci.org/browse/JENKINS-8952)
# when passing environment variables we have to write the tag to a file and
# inject it later again.
mv release.properties release-old.properties || true
echo "TAG = $TAG" > release.properties
# Fail the build if the most recent release tag did not change.
! diff release.properties release-old.properties
Run Code Online (Sandbox Code Playgroud)
构建 - > 注入环境变量:
Properties File Path: release.properties
Run Code Online (Sandbox Code Playgroud)
构建后操作 - >:在其他项目上触发参数化构建
Projects to build: <your main project>
Trigger when build is: Stable
Parameters: TAG=$TAG
Run Code Online (Sandbox Code Playgroud)
最后,在主构建中,使用以下字符串参数勾选"此构建已参数化"
Name: TAG
Default Value: <your release branch>
Run Code Online (Sandbox Code Playgroud)
在"源代码管理"部分中,在"要构建的分支"字段中使用"$ TAG".
| 归档时间: |
|
| 查看次数: |
25668 次 |
| 最近记录: |