Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am china OpDevs. Write Chinese Install and Configured doc #155

Open
PGDream opened this issue Aug 29, 2016 · 1 comment
Open

I am china OpDevs. Write Chinese Install and Configured doc #155

PGDream opened this issue Aug 29, 2016 · 1 comment

Comments

@PGDream
Copy link

PGDream commented Aug 29, 2016

sputnik 安装
sputnik 介绍地址 http://labs.criteo.com/2015/02/static-code-analysis-do-it-the-right-way/
sputnik git地址 https://github.com/TouK/sputnik
.下载已经打包的sputnik,把sputnik安装到jenkins服务器,如果有slave的也得安装,git地址会有很详细的安装介绍,要注意就是一些配置
.在安装的时候最好根据文档提供的建议目录安装,安装完后在sputnik根目录创建gerrit.properties
.gerrit.properties文件内容可以复制文档提供内容,需要修改的有
connector.type=gerrit 不变
connector.host=your.host.com 填写自己gerrit的host就可以
connector.path=/gerrit 如果没有path就可以配置为空
connector.port=8080 如果端口为80配置可以为空
connector.username=sputnik 用户名和密码是gerrit的用户名和密码,是用code review的用户,密码在用户配置里面有http password生成的密码
connector.password=PassWd

jenkins sputnik 配置
.gerrit trigger-->Trigger on多配置几个选项就是代码push到gerrit层就触发构建
.git--->高级--Refspec 必须要配置为$GERRIT_REFSPEC,不然不会触发构建
.git--->Additional Behaviours--->Strategy for choosing what to build 配置项选Gerrit Trigger
.以上jenkins配置完成后基本可以跑来,但是要使用sputnik自动code review还少些配置,回到github文档复制到Execute Shell里面
/opt/sputnik/bin/sputnik --conf /opt/sputnik/gerrit.properties --changeId $GERRIT_CHANGE_ID --revisionId $GERRIT_PATCHSET_REVISION

可能是gerrit trigger的插件版本的原因,在jenkins里面拿不$GERRIT_CHANGE_ID $GERRIT_PATCHSET_REVISION,我们使用个土办法,就是使用shell命令获取

GERRIT_KEY_WORD=$(git log -1|tail -1)
GERRIT_CHANGE_ID=$(git log -1|tail -1|cut -d " " -f 6)
GERRIT_PATCHSET_REVISION=$(git rev-parse HEAD)
GIT_LOG_KEY_WORD="Change-Id"

if [[ "$GERRIT_KEY_WORD" =~ $GIT_LOG_KEY_WORD ]]; then
    /opt/sputnik/bin/sputnik --conf /opt/sputnik/gerrit.properties --changeId $GERRIT_CHANGE_ID --revisionId $GERRIT_PATCHSET_REVISION
    echo "exit 0 workaround"
fi

配置完以上配置后就能正常的使用sputnik来code review,Execute Shell的添位置顺序也会导致执行顺序的变化

.jenkins打包给gerrit打分需要在gerrit trigger (Jenkins-->Gerrit Trigger)全局配置里面配置 Gerrit Reporting Values(包涵Verify,Code Review)根据实际情况配置好分数
.注意点jenkins连接gerrit和sputnik连接gerrit不能使用同一个帐号,不然打分时会有覆盖的情况发生

.总结在安装和使用sputnik的时候一定要分清楚jenkins打分及sputnik打分,要一步步来实现及测试

@SpOOnman
Copy link
Collaborator

Thanks. Can you edit Wiki here and add a new page? https://github.com/TouK/sputnik/wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants