Groovy Script for Jenkins Script Console to Add or Replace Subversion Repository Browser

In my last post I showed how to rename the host name for Subversion in all jobs with one script. In this post I will show you how to set the repository browser in all jobs with one script. This script is based on the script from my last post.

 1def newRepositoryBrowserRootUrl = new URL("http://root.url.to.your.sventon.instance")
 2def newRepositoryInstance = "repository-instance-name"
 3def newRepositoryBrowser = new  hudson.scm.browsers.Sventon2(newRepositoryBrowserRootUrl, newRepositoryInstance)
 4
 5Hudson.instance.items.each { item ->
 6
 7    if(item.scm instanceof hudson.scm.SubversionSCM) {
 8        println("JOB: " + item.name)
 9
10        def newScm = new hudson.scm.SubversionSCM(Arrays.asList(item.scm.locations), item.scm.workspaceUpdater,
11            newRepositoryBrowser, item.scm.excludedRegions, item.scm.excludedUsers, item.scm.excludedRevprop, item.scm.excludedCommitMessages,
12            item.scm.includedRegions, item.scm.ignoreDirPropChanges, item.scm.filterChangelog)
13
14        item.scm = newScm
15        item.save()
16
17        println("New Repository Browser: " +  item.scm.browser.class)
18        println("\n=================\n")
19
20    }
21}

As aforementioned the above Groovy script uses Sventon 2.x as Subversion repository browser. However, Jenkins supports more Subversion repository browsers originally like

  • Assembla
  • CollabNetSVN
  • FishEyeSVN
  • SVNWeb
  • Sventon 1.x
  • ViewSVN
  • WebSVN

Jenkins supports other Subversion repository browsers by plugins like

  • Polarion WebClient  for Subversion
  • WebSVN 2.x

If you want to use an another Subversion repository browser, you have to change the first three lines:

1def newRepositoryBrowserRootUrl = new URL("http://root.url.to.your.sventon.instance")
2def newRepositoryInstance = "repository-instance-name"
3def newRepositoryBrowser = new  hudson.scm.browsers.Sventon2(newRepositoryBrowserRootUrl, newRepositoryInstance)

For example, if you want to use SVNWeb as Subversion repository browser, you have to add following lines instead of the aforementioned lines:

1def newRepositoryBrowserUrl = new URL("http://root.url.to.your.svn")
2def newRepositoryBrowser = new hudson.scm.browsers.SVNWeb(newRepositoryBrowserUrl)
  1. Blog Post - Groovy Script for Jenkins Script Console to Rename the Subversion Host Name
  2. Overview about supported Subversion repository browser by Jenkins
  3. Polarion Plugin
  4. WebSVN2 Plugin