Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I change the working directory when I run a script with ant sshexec in Jenkins?
    primarykey
    data
    text
    <p>I have a ant target where I successfully use a sshexec-task to install a server using tomcat on OpenSuse 11.</p> <p>My problem comes when I try to run a script that start the newly installed server. I need to do this as root, so I use a task as this:</p> <pre><code>&lt;sshexec host="${tss.hostname}" username="${username}" password="${password}" trust="true" Command="/usr/local/bin/foo/bar/tomcat/bin/startup.sh" failonerror="false"/&gt; </code></pre> <p>The problem with this is that I need to run the script from the folder where it is located, as it finds CATALINA_HOME and JAVA_HOME from that location. And the path "foo/bar" will change over time so I do not want to set it permanently. I just want to change my running path to the correct one.</p> <p>As I failed to start the server like that, I wanted to investigate a bit and changed the script so I used "CommandResource="cmd.txt" instead of a direct command. I thought I could use this to set CATALINA_HOME before I started the server and go around the problem that way.</p> <p>This is the outcome when using cmd.txt:</p> <pre><code> [sshexec] Connecting to foo-bar:22 [sshexec] cmd : [sshexec] cmd : cd /usr/local/bin/foo/bar/tomcat/bin [sshexec] cmd : pwd [sshexec] /root [sshexec] cmd : echo $PATH [sshexec] /usr/java/jdk1.6.0_27/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin [sshexec] cmd : export CATALINA_HOME=$PATH:/usr/local/bin/tibco/tss/4.5.0/tomcat [sshexec] cmd : echo $PATH [sshexec] /usr/java/jdk1.6.0_27/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin </code></pre> <p>This shows that neither the cd nor export command have any effect.</p> <p>I suspect I need to change the rights for ssh. I have read that I may need to change in .ssh/config. But I do not know how or where...</p> <p>So, to sum this long question up short: </p> <p>What do I need to do to be able to run my startup.sh as root from the correct tomcat/bin folder with a ant script that is run in Jenkins?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload