如何将SVN存储库链接到Jenkins Job。

时间:2015-11-05 14:59:10

标签: jenkins jenkins-cli

有没有办法使用Jenkins-cli jar或Jenkins xml / json api获取Jenkins Job。?

我确实有办法从上次成功的构建调用中获取它。但是,我正在考虑一项没有任何构建的工作。我尝试使用jenkins-cli的get-job选项,但它抛出异常说,我没有广泛的读权限。

1 个答案:

答案 0 :(得分:0)

您可以通过http://jenkins:8080/job/jobnameE/config.xml检索整个作业配置。

查找XML文档中的scm节点。您可以在scm/locations/hudson.scm.SubversionSCM_-ModuleLocation/remote找到存储库。

示例scm节点如下所示:

<scm class="hudson.scm.SubversionSCM" plugin="subversion@2.5.1">
    <locations>
        <hudson.scm.SubversionSCM_-ModuleLocation>
            <remote>http://source/svn/MyProject/trunk</remote>
            <credentialsId>74fc995c-2005-4b6e-9911-f231995b48bb</credentialsId>
            <local>MyProject</local>
            <depthOption>infinity</depthOption>
            <ignoreExternalsOption>false</ignoreExternalsOption>
        </hudson.scm.SubversionSCM_-ModuleLocation>
        <hudson.scm.SubversionSCM_-ModuleLocation>
            <remote>http://source/svn/OtherProject/trunk</remote>
            <credentialsId>74fc995c-2005-4b6e-9911-f231995b48bbc</credentialsId>
            <local>OtherProject</local>
            <depthOption>infinity</depthOption>
            <ignoreExternalsOption>false</ignoreExternalsOption>
        </hudson.scm.SubversionSCM_-ModuleLocation>
    </locations>
    <excludedRegions/>
    <includedRegions/>
    <excludedUsers/>
    <excludedRevprop/>
    <excludedCommitMessages/>
    <workspaceUpdater class="hudson.scm.subversion.UpdateUpdater" />
    <ignoreDirPropChanges>false</ignoreDirPropChanges>
    <filterChangelog>false</filterChangelog>
</scm>

如果您需要身份验证,那么您应该阅读: Authenticating scripted clients