Jenkins Subversion post-commit hook with authentication - 仍然需要匿名作业读取?

时间:2014-05-23 18:28:42

标签: svn jenkins post-commit-hook

我们正在为我们的许多项目构建使用Subversion 1.8.8和Jenkins 1.509.4(使用Subversion v2.3插件)。公司策略需要身份验证,因此在Jenkins中我们使用LDAP安全领域,基于项目的安全矩阵用于用户全局和项目授权。我们的SVN post-commit钩子通过使用专为此场合创建的LDAP服务帐户与Jenkins交谈。实现这一点时,我意识到为了使钩子实际上触发作业,即使发送了有效的用户名/密码,也不足以将该帐户列为在安全页面上具有对Jenkins的完全访问权限;仍然需要匿名的Job Read访问权限。还有人指出,服务帐户根本不需要任何明确的访问权限。对于有问题的作业,启用轮询。我们尝试了一个明确的时间表(我试过H 0 1 1 *)并没有明确的时间表。

此配置的副作用是Jenkins的有效用户可以查看服务器上的每个作业。这是一个问题,因为这为用户提供了200多个工作,大多数用户只关心其中的一小部分。

是否有配置允许对提交后挂钩进行身份验证,而不在Jenkins中启用任何匿名访问?

作为参考,我们的post-commit钩子如下所示:

SVNLOOK=/usr/bin/svnlook
REPOS="$1"
REV="$2"
UUID=`${SVNLOOK} uuid $REPOS`
PW_SCRIPT=/home/ci/bin/get_ci_pw.sh
if [ ! -f $PW_SCRIPT ]; then
    exit 0
fi
JENKINS_USER=ci
JENKINS_PW=`$PW_SCRIPT`
if [ "x$JENKINS_PW" = "x" ]; then
    exit 0
fi
if [ "x${UUID}" = "x" ]; then
    exit 1
fi
echo "${UUID} : ${REV} : ${REPOS}" >> /tmp/post_commit.out
/usr/bin/wget \
    --connect-timeout=5 \
    --tries=2 \
    --http-user=$JENKINS_USER --http-password=$JENKINS_PW \
    --header "Content-Type:text/plain;charset=UTF-8" \
    --post-data "`${SVNLOOK} changed --revision $REV $REPOS`" \
    --output-document /tmp/post-commit-wget \
    http://ciserver:8888/subversion/${UUID}/notifyCommit?rev=${REV}
exit 0

在上面的配置中,我能够在Jenkins日志中找到这些信息:

  

2014年5月27日下午3:36:12 INFO   org.springframework.web.context.support.StaticWebApplicationContext   prepareRefresh刷新

     

org.springframework.web.context.support.StaticWebApplicationContext@25e3951:   显示名称[Root WebApplicationContext];启动日期[5月27日星期二   2014年12:15:12 EDT];上下文层次结构的根

     

2014年5月27日下午3:36:12 INFO   org.springframework.web.context.support.StaticWebApplicationContext   obtainFreshBeanFactory

     

应用程序上下文的Bean工厂   [org.springframework.web.context.support.StaticWebApplicationContext@25e3951]:   org.springframework.beans.factory.support.DefaultListableBeanFactory@9466053

     

2014年5月27日下午3:36:12 INFO   org.springframework.beans.factory.support.DefaultListableBeanFactory   的preInstantiateSingletons

     

预先实例化单身人士   org.springframework.beans.factory.support.DefaultListableBeanFactory@9466053:   定义bean [filter,legacy];工厂层级的根

     

2014年5月27日下午3:36:30警告   hudson.scm.SubversionRepositoryStatus $ JobTriggerListenerImpl onNotify

     

未找到任何颠覆作业

     

2014年5月27日下午3:36:30 INFO   jenkins.scm.impl.subversion.SubversionSCMSource $ ListenerImpl onNotify

     

从47272b4f-b969-45fb-85a3-5cc10733bede收到提交后挂钩   在路径上修订1,995   [mdeneaul / TIJ4 /支链/ 1.1-SNAPSHOT / pom.xml中]

     

2014年5月27日下午3:36:30 INFO   jenkins.scm.impl.subversion.SubversionSCMSource $ ListenerImpl onNotify

     

UUID没有颠覆消费者47272b4f-b969-45fb-85a3-5cc10733bede

     

2014年5月27日下午3:36:30警告hudson.scm.SubversionRepositoryStatus   doNotifyCommit

     

对存储库UUID的更改没有兴趣   发现47272b4f-b969-45fb-85a3-5cc10733发现

1 个答案:

答案 0 :(得分:0)

您的Jenkins JOB是否配置为轮询到SVN? 从功能上讲,Post提交挂钩不应该要求从CI到SVN的轮询,但是仍然需要将JOB配置为轮询模式,可以保留每日,每周或每年的任何值。 这样它就会打开Jenkins JOB来监听来自SVN的post commit调用,因为默认情况下它不会监听这些调用。