soundararajan.c soundararajan.c - 1 year ago 94
Groovy Question

How to display direcotry names in Jenkins drop down

I wish to display the directory names(not abs. path) of the Jenkins server's /tmp directory in the Jenkins Drop Down using

Active choice Reactive parameter Plugin

I have displayed it by using the below code.
but it was displaying along with its path in the output.

Eg output:



I need the output as :( without the path of the directory)



code used in groovy script part of " Active choice Reactive parameter Plugin "


def list = []

def dir = new File("/tmp/")
dir.eachFileRecurse (FileType.FILES) { file ->
list << file

list.each {
println it.path

Rao Rao
Answer Source

Here you go:


import static

def list = []

new File('/tmp').eachFileRecurse (DIRECTORIES) { file ->
  list <<
println list

If you do not need recursive, just use eachFile instead of eachFileRecurse.

EDIT: Based on OP's comments, Use return list instead of print list as last statement in the above script as to show list in the jenkins.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download