如何在jenkins中使用已登录的用户凭证列出svn文件夹作为构建参数? [英] how can i list svn folders with the logged in user credential in jenkins for build parameters?

查看:114
本文介绍了如何在jenkins中使用已登录的用户凭证列出svn文件夹作为构建参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过颠覆为我们的构建环境工作设置詹金斯(jenkins).我想使用构建参数列出具有当前用户凭据的Subversion文件夹列表.我为此做了很多搜索,但是我找不到从jenkins登录的用户credentail列出svn文件夹的方法吗?我使用了List Subversion Tags,ExtendedChoice参数和许多插件来做到这一点.收集构建参数时,有什么方法可以使用当前登录的用户凭证连接到Subversion?

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 ?

推荐答案

下面的常规脚本解决了该问题.该脚本可与任何支持groovy的参数插件一起使用.

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

这篇关于如何在jenkins中使用已登录的用户凭证列出svn文件夹作为构建参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆