连接到svn信息库之前,我们可以在jenkins中使用隧道吗? [英] can we use tunnelling in jenkins before connecting to the svn repository?

查看:152
本文介绍了连接到svn信息库之前,我们可以在jenkins中使用隧道吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在访问我的SVN存储库之前,我需要先创建一个tunnel,例如:

Before accessing my SVN repository, I need to create a tunnel first like this :

ssh -L 9898:some_server.com:9898 user@another_server.com

之后,我可以在localhost的端口9898处访问存储库.在创建Jenkins作业时,我可以将SVN网址提供为localhost,并且Jenkins能够访问存储库,但是我仍然必须在服务器上手动创建隧道.有什么方法可以让Jenkins自动化,以便如果对隧道的访问失败,则可以进行隧道化,然后重试?

After that, I am able to access the repository at port 9898 of my localhost. While creating the Jenkins job, I can provide the SVN url as the localhost, and Jenkins is able to access the repo, but I still have to manually create a tunnel on the server. Is there any way that I can automate that with Jenkins, so that if the access to the tunnel fails, then it can do the tunnelling, and try again ?

我正在使用Jenkins 1.487

推荐答案

您需要类似 pre-scm-buildstep

这使您可以在SVN检出之前执行构建步骤. 使用此功能,您可以配置一个步骤,该步骤将在SVN检出开始之前为您打开隧道.

This allows you to execute build steps before the SVN checkout.
Using this, you can configure a step that would open the tunnel for you, before the SVN checkout begins.

但是,我怀疑SVN轮询是否可以在这种情况下使用.

However, I doubt SVN polling would work in such scenario.

更新: 在OP问题之后,这是另一种可能的解决方案:
https://wiki.jenkins-ci.org/display/JENKINS/ScriptTrigger+Plugin
我自己没有使用过它,但是它允许执行自定义外壳程序脚本,而不是常规轮询.您可以使用此自定义脚本首先建立隧道,然后轮询SVN更改.但是,您必须编写自己的脚本才能进行实际的SVN轮询.就像检查工作区修订版(svn info <LocalCheckOut>|grep Revision)并将其对照存储库(svn info <URL>|grep Revision)一样简单.该插件可让您以cron格式安排轮询频率.

Update: Following OP questions, here is another possible solution:
https://wiki.jenkins-ci.org/display/JENKINS/ScriptTrigger+Plugin
I have not used it myself, but it allows a custom shell script to be executed instead of the regular polling. You can use this custom script to establish a tunnel first, and then poll for SVN changes. You would have to write up your own script for doing the actual SVN poll however. Something as simple as checking the workspace revision (svn info <LocalCheckOut>|grep Revision) and checking it against the repository (svn info <URL>|grep Revision). The plugin will allow you to schedule frequency of polls in cron format.

另一种懒惰的方式是使用此插件,建立隧道,进行SVN更新(无论是否有更改),然后由工作来构建它.然后,您可以执行常规的构建操作,该操作将在实际构建步骤之前检测实际上是否有新的签出.

An alternative lazy way of doing it would be to use this plugin, establish the tunnel, do SVN update (whether there are changes or not), and then let the job build it. You can then have a regular build action that would detect if there was in fact new checkout or not, before the real build step.

这篇关于连接到svn信息库之前,我们可以在jenkins中使用隧道吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆