2014-05-01 241 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

我如何將密碼隱藏在這裏? –