- Make zip file.
- Run command.
- Copy files to remote machine.
- Run commands on Remote Linux machine.
- Open an input box and respond to input value.
- Make an ant call.
1. Make zip file:
Following is the xml for making zip file in ant:
1 | < zip destfile = '${destination.folder}/zipName.zip' > |
2 | < fileset dir = '${Source.folder}' /> |
3 | </ zip > |
2. Run commands:
Here I will show you how to start tomcat in ant file to demonstrate how to run commands in ant. Following is the xml for this:
1 | < exec dir = '${tomcat.home}/bin' executable = 'cmd' os = 'Windows XP' > |
2 | < arg line = '/c startup.bat' /> |
3 | </ exec > |
Note: To run following commands you will need JSCH jar.
3. Copy files to remote machine:
1 | < copy file = '${source.folder.file} ' todir = '\\remote\path' > |
2 | </ copy > |
1 | < scp file = '${source.folder.file} ' todir = '${remote.user}@${remote.host}:${remote.path.where.to.do.copy}' |
2 | password = '${remote.password}' trust = 'true' > |
3 | </ scp > |
4. Run commands on remote machine:
You can use following tag to execute commands on remote Linux machine.
1 | < sshexec host = '${remote.host}' username = '${remote.username}' password = '${remote.password}' |
2 | command = '${command.to.run}' trust = 'true' /> |
1 | < sshexec host = '${remote.host}' username = '${remote.user}' password = '${remote.password}' |
2 | command = 'sh ${tomcat.home}/startup.sh' trust = 'true' /> |
5. Open an input box and respond to input value:
To open an input dialog use following tag:
1 | < input message = 'Enter id: ' addproperty = 'my.id' > |
2 | </ input > |
1 | < condition property = 'do.abort' > |
2 | < equals arg1 = 'n' arg2 = '${my.id}' /> |
3 | </ condition > |
4 | < fail if = 'do.abort' >Build aborted by user.</ fail > |
6. Make an ant call:
1 | < antcall target = 'targetName' > |
2 | </ antcall > |
Note: In above examples all values starting with "${"and ending with "}'' are variables and you may have to put appropriate values in them to successfully run them.
No comments:
Post a Comment
Thanks for your comments ! Please do leave feedback