Jenkins: SSH Server as Choice Parameter

497 Views Asked by At

I would like the Jenkins job to have a choice parameter (pull-down) containing the SSH servers in the Configuration page under Publish over SSH. Are those servers retrievable via an array variable so that I could use the extensible choice parameter?

Alternatively, if there were such a variable, I could write a simple for-loop that would perform some action on each server.

Answers I've seen so far in SO refer to using the string input parameter for SSH servers.
TIA

GF

1

There are 1 best solutions below

0
On

I found it with a little more research and code trial and error:

import jenkins.model.*
import jenkins.plugins.publish_over_ssh.BapSshHostConfiguration
def inst = Jenkins.getInstance()
def publishSsh = inst.getDescriptor("jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin")
def hostConfigs = publishSsh.getHostConfigurations()
return hostConfigs.name
// or, if you prefer, return hostConfigs.hostName