2017-07-27 35 views
1

我已经在Jenkins设置了一份工作来判定GerritHub.io的评论。 当代码更改被推送审阅时,作业被正确触发,并且Jenkins在GerritHub在构建开始和构建结果时给出注释。在jenkins中我的Gerrit服务器定义被配置为对构建失败,构建不稳定和构建成功进行判定。没有从我的Jenkins到Gerrithub的判决书

但是:没有给出判决票。

更新:在GUI中以Jenkins用户身份登录显示Jenkins用户只具有执行代码审查的权限:-1..1。所以我将Jenkins中的Gerrit服务器设置更改为仅提供Code Review。现在它可以工作,但仅适用于“代码审查”,而不适用于“已验证”。它表明限制在GerritHub.io中,并且应该可以在那里进行配置。

回答

1

请按照有关访问权限的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 
+0

是否有另一种方式比创建一个新的GitHub帐户,并将其链接到GerritHub创建Jenkins用户? 此外,您的答案会使您看起来像直接更改Gerrit配置文件。到目前为止,我只找到了一种通过GerritHub Web UI更改配置的方法。有什么我错过了吗? – fap

+0

据我所知,没有匿名登录,所以为了我的目的,我想创建一个新用户。您可以使用现有帐户,但我喜欢将帐户分开,结果以“Jenkins”作为发件人的名称更好。 –

+0

是的,我直接向GerritHub提交配置文件。这样它可以立即访问。现在从脚本执行它,以便我可以在我的所有项目中重复使用它。 –

相关问题