Ant target to start/stop processes in deployment in Tibco Administrator
Facts - Tibco
Monday, 19 December 2011 21:37

This note has been tested with Tibco Runtime Agent (TRA) 5.6, Tibco Administrator 5.6, Ant 1.8 and Groovy 1.8

Deploying of (BusinessWorks) ear files in Administrator is often easier using a script calling AppManage (in the TRA distribution) than doing it manually in the Administrator web frontend. With scripted deployments the ear file and the deployment xml file containing the process and global variable settings is usually extracted from a version control system. So a working scripted deployment guarantees that these settings will not be lost. In addition a scripted deployment can be even easier executed via a web frontend or built system such as Jenkins.

In some cases deployed processes should not be stopped and restarted during deployment. For example when the tra file needs to be (manually or scripted) updated after deployment. Or when processes are running load balanced and should not have any downtime. Administrator facilitates such deployments, but it can be beneficial to do such deployments in a scripted way. The following targets stop and start processes in Tibco Administrator using AppManage called from ant.

The following ant target starts or stops processes in a deployment within Tibco Administrator:

<target name="startOrStopApplications">
  <groovy>
    def appName = properties.get("tibco.app.name")
    def tibcoAdminDomain = properties.get("tibco.admin.domain")
    def bwHost = properties.get("tibco.admin.host")
    def sshUser=properties.get("ssh.user")
    def sshPassword=properties.get("ssh.password")
    def traBinDir=properties.get("serverTibcoInstallationDir") +"/tra/5.6/bin"
 
    def service = ""
    if (properties.get("tibco.app.service") != null) {
      service = " -service " +properties.get("tibco.app.service") +" "
      System.out.println("Starting service " +properties.get("tibco.app.service") 
+" of application " +appName +"...")
    } else {
      System.out.println("Starting all services of application " +appName +"...")
    }
 
    def startOrStop = properties.get("tibco.app.startOrStop")
 
    ant.sshexec (
      trust:"true",
      host:bwHost,
      username:sshUser,
      password:sshPassword,
      command:"cd " +traBinDir +"; ./AppManage -" +startOrStop +" 
-app " +properties.get("tibco.admin.dir") +"/" +appName +service +" -domain " +tibcoAdminDomain 
+" -user " +properties.get("tibco.admin.user") +" -pw " +properties.get("tibco.admin.password") 
+"; tail -n 30 " +properties.get("serverTibcoInstallationDir") +"/tra/domain/" +tibcoAdminDomain 
+"/logs/ApplicationManagement.log > ~/AMLast30Lines.log",
      failonerror:"false"
    ) { }
  </groovy>
  <scp trust="true" file="${ssh.user}:${ssh.password}@${tibco.admin.host}:~/AMLast30Lines.log" 
  todir="."/>
</target>

Note several ant properties. These can be supplied from the command line or from Jenkins/Hudson:

  • Administrator host ssh credentials: tibco.admin.host, ssh.user, ssh.password
  • Name of Tibco Administrator domain: tibco.admin.domain
  • Deployment to start or stop: tibco.app.name, in Administrator directory tibco.admin.dir
  • Optional service such as an adapter, or process archive (.par) to start or stop: tibco.app.service
  • Start or stop: tibco.app.startOrStop with value "start" or "stop".