2014-05-01 154 views
3

犯我如何提交一个文件使用的摇篮SVN 1.7库?SVN与摇篮

我想使用詹金斯提供凭证,提交信息和文件路径。

回答

3

this answer绘画,这是摇篮的任务,使用SVNKit提交一个文件。

buildscript { 
    repositories { mavenCentral() } 
    dependencies { classpath "org.tmatesoft.svnkit:svnkit:1.7.11"} 
} 

import org.tmatesoft.svn.core.wc2.* 
import org.tmatesoft.svn.core.wc.* 
import org.tmatesoft.svn.core.* 

task svnCommitFile(){ 
    description = "Commits a single file to an SVN repository" 
    doLast{ 
     if (!project.hasProperty("commitMsg")){ 
      ext.commitMsg = "None" 
     } 
     SvnOperationFactory svnOperationFactory = new SvnOperationFactory() 
     def authentication = SVNWCUtil.createDefaultAuthenticationManager(svnUser, svnPassword) 
     svnOperationFactory.setAuthenticationManager(authentication) 
     try { 
      SvnCommit commit = svnOperationFactory.createCommit() 
      commit.setSingleTarget(SvnTarget.fromFile(new File(fileToCommit))) 
      commit.setCommitMessage(commitMsg) 
      SVNCommitInfo commitInfo = commit.run() 
      println "Commit info: " + commitInfo 
      println "Commit message: " + commitMsg 
     } finally{ 
      svnOperationFactory.dispose() 
     } 
    } 
} 


如果提交与詹金斯后每完成承诺项目调用它,你会得到一个无限构建循环,因为一个承诺导致生成这会导致因此Jenkins应该忽略它自己的提交:在你的项目的构建配置中,去Source Code Management --> Subversion --> Advanced并且把jenkins(或者你叫你的自动提交者)添加到Excluded Users

+0

这是否照顾首先将文件SVN的,如果需要的话,或将需要额外的代码? –

+0

我敢肯定它添加到SVN第一,不需要额外的代码。 –

+0

我如何将密码隐藏在这里? –