mfidan
mfidan

Reputation: 647

how can i list svn folders with the logged in user credential in jenkins for build parameters?

I am trying to set up jenkins for our build environment work with subversion. I want to list subversion folder list with current user's credential for a build parameter. I googled a lot for this but i cant find a way to list the svn folders with the logged in user credentail from jenkins ? I used List Subversion Tags , ExtendedChoice parameter and lots of plug-ins to do this. Is there any way to use currently logged in user's credential to connect to subversion while collecting the build parameters ?

Upvotes: 2

Views: 2390

Answers (1)

mfidan
mfidan

Reputation: 647

The groovy script below solve the issue. The script can be used with any of groovy supported parameter plugin.

def user = hudson.model.User.current();
def a = jenkins.model.Jenkins.getAuthentication()
def userId = user.getId() 
def pass =a.getCredentials()
def svnurl = 'http://yoursvnurl'
def dirs = [] 
def command = ['svn', 'list', svnurl , '--username' , userId , '--password' , pass ]
def proc = command.execute()
print command
proc.in.eachLine {dirs.add(it) }
return dirs

Upvotes: 6

Related Questions