我配置了一个 TeamCity 代理来构建我的 XCode 项目,并且我使用 github。我想在我的发行说明中自动包含 TeamCity 中所有待定提交的描述。
如何从 github 获取它们并将它们存储在 teamcity 中?一旦我将它们放入 teamcity 变量中,我就可以轻松地将它们添加到我的构建脚本中。
最佳答案
这就是我最终使用 bash 脚本执行此操作的方式:
#!/bin/bash
curl -o lastBuild.tmp "http://localhost:8111/app/rest/buildTypes/id:bt2/builds/status:SUCCESS" --user rest:rest
last_commit=`xpath lastBuild.tmp '/build/revisions/revision/@version'| awk -F"\"" '{print $2}'`
echo "##Last commit = $last_commit"
# prepare build notes
NOTES=`git log --pretty=format:"- %s" $last_commit..origin/master`
echo "this is it:$NOTES"
一些解释:
- 使用
curl
从您的构建配置中获取最后一次成功的构建。在我的示例中,这是 bt2,请确保将其替换为您的 - 使用 XPath/AWK 解析 XML 响应并获取最新的 git 版本
- 使用
git log
从上次构建中获取所有更改,并根据需要格式化它们。我只想获取提交说明。
关于git - 如何为 TeamCIty 中的未决更改编写 git 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10794300/