Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building SVN trunk, branches, and tags, in Jenkins?

Tags:

svn

jenkins

I'm trying to create a job, in Jenkins, that will allow me to build a project that's stored in Subversion, but will ask me which tag, branch, or the trunk I want to build.

I've tried making it a parameterized build, adding a "List Subversion tags" parameter, but that creates a dropdown with just /branches, /tags, and /trunk. It doesn't list the individual branches or tags.

I'd thought that using the Subversion Release Manager would manage this, but it provides no meaningful documentation on how to use it, and all my attempts to use it so far have resulted in it not asking me for a branch, but proceeding to checkout the entire tree - trunk and every branch and tag.

Jenkins Issue 10678 was supposed to have provided this, but that was back in 2011, and if it's still supposed to work, I've not been able to make it work for me.

Does anyone know how to make this happen?

like image 890
Jeff Dege Avatar asked Oct 01 '22 20:10

Jeff Dege


1 Answers

You can use variables for repository locations so your repository URL in jenkins would look something like http://myhost.com/MY_REPO/${some_branch}, where some_branch is your parameter. This parameter can be set as a string parameter you can manually enter, or you can get fancy with a dynamic choice parameter and have it autofill a dropdown menu with information from the repository (https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Dynamic+Parameter+Plug-in). Example:

Dynamic Choice Parameter: 'some_branch'

// Choices Script (groovy)
def dirs = ['trunk/'] // defaults to trunk

def command = ['svn', 'ls', 'http://myhost.com/MY_REPO/tags']
def proc = command.execute()
proc.in.eachLine { dirs.add('tags/' + it) }

command = ['svn', 'ls', 'http://myhost.com/MY_REPO/branches']
proc = command.execute()
proc.in.eachLine { dirs.add('branches/' + it) }

dirs
like image 74
racosta Avatar answered Oct 04 '22 22:10

racosta