Edd*_*Edd 5 git teamcity github sonarqube
我有一个TeamCity(版本2017.2.4)项目,其中包含多个配置,这些配置附加到各种GitHub存储库.现在我想为其中一些配置设置SonarQube GitHub插件.为此,我创建了一个新的构建并附加了一个VCS Trigger.为了使这个触发器工作,我还附加了我想要运行的所有VCS根目录.现在,在对这些VCS根进行任何更改之后,将触发构建.
为了使用这个插件,在每次触发后我需要提取受影响的存储库名称并获取拉取请求ID.如果我有一个带有以下脚本的VCS根目录,这很容易做到:
#!/usr/bin/env bash
# Exit script on any command failure.
set -e
# Pass parameter to next TeamCity build step.
param() {
echo "##teamcity[setParameter name='$1' value='$2']"
}
# Full GitHub repository name.
repository="myOrg/$(echo '%vcsroot.url%' | grep -oP '(?<=\/).*(?=\.git)')"
# Full URL to fetch branch pull request info.
url="https://api.github.com/repos/${repository}/pulls"
url="${url}?head=%teamcity.build.branch%"
url="${url}&access_token=%github.authToken%"
echo "Fetching PR information from: ${url}"
res=$(curl "${url}" -f)
echo "Parsing PR id from:"
echo "${res}"
pullRequest=$(echo "${res}" | grep -oP -m 1 '(?<=pulls\/)\d+(?=",)')
if [ -z "${pullRequest}" ]; then
echo "Could not parse PR id from: ${res}"
exit 1
fi
# Pass parameters to next build step which will init the plugin.
param 'github.pullRequest' ${pullRequest}
param 'github.repository' ${repository}
Run Code Online (Sandbox Code Playgroud)
但是因为我有多个VCS根,所以我无法引用%vcsroot.url%,所以:
| 归档时间: |
|
| 查看次数: |
148 次 |
| 最近记录: |