5
votes

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?

3

3 Answers

5
votes

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
0
votes

I am using the subversion plugin and it works really fine. Not sure if there are some changes since you posted the question.

Just a note to beginners to set up the plugin.

It provides a step by step solution with screenshots.

-1
votes

Declarative or scripted pipeline? I've had good luck w ListSubversionTagsParameterDefinition plugin + the following in my scripted pipelines...

parameters([
    [$class: 'ListSubversionTagsParameterDefinition',
            name: 'SVN_TAG_TO_BUILD', 
            tagsDir: 'https://server/svn/repo/tags', 
            credentialsId: 'jenkins', 
            maxTags: '50', 
            reverseByDate: true, 
            reverseByName: false], 
    string(
        defaultValue: 'Running release build', 
        description: 'Comments to leave when creating the release build tag', 
        name: 'SVN_COMMENTS'
    )
])