script / cibuild:使用Jenkins构建时权限被拒绝

时间:2013-03-03 21:47:28

标签: git github jenkins

使用Jenkins构建时出现以下错误:

Building in workspace /var/lib/jenkins/jobs/test-1b8ac945ebc2383345391847605819c5/workspace
[workspace] $ /bin/sh -xe /tmp/hudson5014904737097448499.sh
+ [ ! -d ./.git ]
+ git fetch -q origin
+ git reset -q --hard a3ff7b59246560719bc3a8f2e89f0b5720fa32c3
+ [ -f script/cibuild ]
+ script/cibuild
/tmp/hudson5014904737097448499.sh: 9: /tmp/hudson5014904737097448499.sh: script/cibuild: Permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE

配置脚本是janky默认值:

if [ ! -d "./.git" ]; then
  git init
  git remote add origin git@github.com:repo/my_repo
fi
git fetch -q origin
git reset -q --hard $JANKY_SHA1
if [ -f script/cibuild ]; then
  script/cibuild
else
  bundle install --path vendor/gems --binstubs
  bundle exec rake
fi

我已经创建了自己的脚本/ cibuild,但是从错误中看,它看起来没有正确的权限。如何从Jenkins自动正确设置权限?文件本身存储在repo中,所以我不想每次都登录Jenkins并设置权限。

感谢所有帮助。

1 个答案:

答案 0 :(得分:1)

要解决这个问题,如果脚本/ cibuild存在,我添加了chmod 700 script/cibuild。要使此更改在Janky中是全局的,您需要编辑Janky文件夹中的config / default.xml.erb

if [ ! -d "./.git" ]; then
  git init
  git remote add origin git@github.com:repo/my_repo
fi
git fetch -q origin
git reset -q --hard $JANKY_SHA1
if [ -f script/cibuild ]; then
  chmod 700 script/cibuild
  script/cibuild
else
  bundle install --path vendor/gems --binstubs
  bundle exec rake
fi