Jenkins - SSH command executor - selector
<p>I have Jenkins question this time. I have few app servers, each app server has multiple tomcats. What i want to achieve is a command selector. For example: i have APP01, APP02, APP03. Each app server has few tomcats: tomcat01, tomcat02, tomcat03, ..... When I deploy i run my special script that does backup of existing app, backup of logs, cleanup,  placing .war file into correct directory and start tomcat. the command is</p>

<pre><code>app-new-execute deploy
</code></pre>

<p>I have also -warage (check for .war file date), -stop, -start, -kill (if something goes wrong). Users have to requests deployments from me, or they have to login themselves and perform deployment. They have permissions to do it (via sudoers file) and nothing more than that - but sometimes things get messy. I have multiple build jobs in Jenkins. Now ... is it possible to have selector - for example 2 drop down lists where users could choose server (let say) APP03 and tomcat (let say) TOMCAT06. Question 1: Is it possible that JENKINS could build me command (based on selector) </p>

<pre><code>ssh APP03 sudo su - TOMCAT06 -c 'app-new-execute "deploy"'
</code></pre>

<p>QUESTION2: can that list be dynamic (txt file). The reason for it is - i remove/move/delete tomcats regularly. There are wholes in names like (tomcat 01,02,07,08). What i would do is to create a TXT file called $(hostname).txt on each server and i could get a tomcat numbers from simple script (cron, daily). Something like: <code>echo $(hostname) &gt; $(hostname).txt</code> and output tomcat numbers using some simple script like <code>ll /applications/new/tomcat/ | egrep ^d | grep tomcat | awk '{print $3}</code>. That will give me tomcat01, tomcat03,tomcat07 ....
Is it possible that Jenkins could populate list of tomcats per server from that .txt file. If not what would be ta better method to achieve something like it? I am not a master in Jenkins - i have set multiple build jobs (SVN+ANT). Any suggestion is welcome. Regards</p>

<p>Progress:
I was able to get Extended Choice Parameter. Works as a charm. I get server as well as tomcat. It was (as described) easy. What i have is a SSH executor. I choose server, type tomcat number and can perform remote SSH. I do have SSH key auth and can successfully login to the server. Jenkins can easily connect to the server. However i have an SSH problem - when executing remote SSH - Jenkins can not "finish" SSH session. It stuck with spinning logo waiting for something. My parameters are ${server} (choose from the list) and ${tomcat} (type tomcat number).</p>

<pre><code>ssh -t -t app_deployer@${server} &lt;&lt;EOF
sudo su - ${tomcat} -c './deployer_script.sh "deploy"'
echo "You are deploying app on ${server} to ${tomcat}"
EOF
</code></pre>

<p>exit
What i am doing wrong here? I can (from the command line) perform command</p>

<pre><code>sudo su - ${tomcat} -c './deployer_script.sh "deploy"'
</code></pre>

<p>but on the server - logged via SSH to the app server box. What i am missing?</p>

<p>I can not do &lt;&lt; 'EOF' instead of &lt;&lt; EOF - Jenkins will not understand ${tomcat} variable. I can not login to the server as ${tomcat} directly - security. I have a deployer account that has permissions to run that script for every tomcat (security issue) Thank you for your help.</p>

<p>Progress update 2. 
I can not exit from SSH session via shell as well. Command "exit" does not work. 
There has to be error there. after EOF does not quit. 
What am i missing?</p>