按照Jenkins 插件页面上有关访问权限的文档进行操作,但不要添加非交互式用户,而是添加您的 Jenkins 正在使用的用户。(我更喜欢在我的审查裁决中有一个名为“Jenkins”的单独用户)
[access "refs/heads/*"]
label-Code-Review = -1..+1 group user/<Jenkins User Id>
label-Verified = -1..+1 group user/<Jenkins User Id>
默认情况下,代码审查的访问权限似乎已经到位,但无论如何都添加并添加读取权限。访问权限在“访问”选项卡中正常可用。
我为自己制作了一个脚本来简化编辑访问权限。我创建了一次访问权限,并将文件“groups”和“project.config”签入到 github repo。这是脚本:
#!/bin/bash
usage(){
echo "Parameter 1: userid (GitHub & GerritHub)"
echo "Parameter 2: repository name"
exit 1
}
printline(){
echo -e "${GRAY}====================${BLACK}"
}
check(){
if [[ $? -ne 0 ]]; then
echo -e "${RED}Failed: ${1}${BLACK}"
echo $2
rm -rf $tmp
exit 1
else
echo -e "$1 - ${GREEN}DONE${BLACK}"
printline
fi
}
if [[ $# -ne 2 ]]; then
usage
fi
RED='\033[0;31m'
GREEN='\033[0;32m'
GRAY='\033[1;30m'
BLACK='\033[0m' # No Color
userid=$1
repo=$2
organization="FILL IN HERE"
template="FILL IN HERE"
if [[ -z "$userid" ]]; then
usage
fi
if [[ -z "$repo" ]]; then
usage
fi
tmp=$(mktemp -d)
[[ -f ~/.ssh/id_rsa ]] && [[ -f ~/.ssh/id_rsa.pub ]]
check "Check key pair in ~/.ssh/" ""
cd $tmp
git clone git@github.com:${organization}/${repo}.git
check "Clone $repo to $tmp " "(project created in GitHub? https://github.com/organizations/${organization}/repositories/new)"
cd $repo
git remote add GerritHub ssh://${userid}@review.gerrithub.io:29418/${organization}/${repo}
check "Add GerritHub as remote " "(is the project imported to GerritHub? https://review.gerrithub.io/plugins/github-plugin/static/repositories.html)"
git fetch GerritHub refs/meta/config:refs/remotes/GerritHub/meta/config
check "Get current access config" "(is the project imported to GerritHub? https://review.gerrithub.io/plugins/github-plugin/static/repositories.html)"
git checkout GerritHub/meta/config
check "Check out meta/config from GerritHub"
git fetch ssh://git@github.com/${organization}/${template} master && git cherry-pick FETCH_HEAD --strategy-option theirs
check "Get access template from GitHub" ""
git push -f GerritHub HEAD:refs/meta/config
check "Push new access rights to GerritHub" ""
rm -rf $tmp