Posts Jenkins ant script to ssh and restart remote application
Post
Cancel

Jenkins ant script to ssh and restart remote application

  • Call target from pom.xml
1
2
3
4
5
6
7
<configuration>
    <target>
        <ant antfile="${basedir}/build.xml">
            <target name="deploy" />
        </ant>
    </target>
</configuration>
  • Setup profile and list server for that environment
1
2
3
4
5
6
7
<profile>
    <id>dev</id>
    <properties>
        <classifier.type>DEV</classifier.type>
        <server.hostname>localhost</server.hostname>
    </properties>
</profile>
  • Ant ssh and execute commands on remote
1
2
3
4
5
6
7
<sshexec 
    host="${node}"
    username="server" 
    password="${server.password}"
    command=". .bash_profile;
            ./server.sh restart;"
    trust="true" />

Source

This post is licensed under CC BY 4.0 by the author.