请按照有关访问权限的the Jenkins plugin page的文档,但不是非互动用户,而是添加Jenkins正在使用的用户。 (我喜欢在我的评审裁决名为“詹金斯的一个单独的用户)
[access "refs/heads/*"]
label-Code-Review = -1..+1 group user/<Jenkins User Id>
label-Verified = -1..+1 group user/<Jenkins User Id>
的代码审查的访问权限已似乎是在默认地方,但无论在任何情况下添加,并添加读取权限。正常情况下,Access选项卡中提供访问权限。
我为自己制作了一个脚本来简化编辑访问权限。我创建了一次访问权限,并在文件'groups'和'project.config'中检入了github回购。这里的脚本:
#!/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 [email protected]:${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://[email protected]/${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
是否有另一种方式比创建一个新的GitHub帐户,并将其链接到GerritHub创建Jenkins用户? 此外,您的答案会使您看起来像直接更改Gerrit配置文件。到目前为止,我只找到了一种通过GerritHub Web UI更改配置的方法。有什么我错过了吗? – fap
据我所知,没有匿名登录,所以为了我的目的,我想创建一个新用户。您可以使用现有帐户,但我喜欢将帐户分开,结果以“Jenkins”作为发件人的名称更好。 –
是的,我直接向GerritHub提交配置文件。这样它可以立即访问。现在从脚本执行它,以便我可以在我的所有项目中重复使用它。 –