There are two options to deploy WAR and EAR file to JBoss Enterprise Application Platform (EAP) 6:
- You can invoke a shell script on a Linux build agent to scp the application to the server, and then deploy with JBoss Command Line Interface (CLI);
- Or you can use SSH and Copy Files Over SSH tasks to accomplish this task.
- JBoss 6 EAP installed and configured
- Linux machine with cross platform build agent for Team Foundation Server. For detailed instructions check this guide
- SSH and SSH Pass configured
The example bellow use SSH connection to connect in target machine and execute the JBoss CLI commands. The steps required are:
- Create temp directory
- Copy files (Artifact) to temp directory
- Running
jboss-cli.sh
to undeploy old version - Running
jboss-cli.sh
to deploy new version of WAR file - Runnig
jboss-cli.sh
for check deployment status
!/bin/bash
echo "Deployment JBOSS..."
PACKAGETEMP=/tmp/package
echo "Creating temp dir"
sshpass -p P@ssw0rd ssh [email protected] 'mkdir -v $PACKAGETEMP'
echo "Copy files to target server"
sshpass -p P@ssw0rd scp -r -v $AGENT_RELEASEDIRECTORY/JavaBuild/Drop [email protected]:$PACKAGETEMP/hello.war
echo "Running undeploy command"
sshpass -p P@ssw0rd ssh [email protected] '/opt/EAP-6.0.1/jboss-eap-6.0/bin/jboss-cli.sh --connect --controller=127.0.0.1 --user=admin --password=P@ssw0rd --command="undeploy hello.war --server-groups=HelloWorld"'
echo "Running deploy command"
sshpass -p P@ssw0rd ssh [email protected] '/opt/EAP-6.0.1/jboss-eap-6.0/bin/jboss-cli.sh --connect --controller=127.0.0.1 --user=admin --password=P@ssw0rd --command="deploy $PACKAGETEMP/hello.war --server-groups=HelloWorld"'
echo "Check deployment status"
sshpass -p P@ssw0rd ssh [email protected] '/opt/EAP-6.0.1/jboss-eap-6.0/bin/jboss-cli.sh --connect --controller=127.0.0.1 --user=admin --password=P@ssw0rd --command="deployment-info --name=hello.war"'
Add the shell script in source control, or share folder.
Create new release definition add add the task Shell script and enter the path for shell script
Check the configuration bellow:
Running new release and check the log events
- JBoss 6 EAP installed and configured
- Create a SSH service connection endpoint with credentials that has permission to run
jboss-cli.sh
script
- Select the predefined SSH endpoint.
- Copy the application file to the remote server
- You can define any secret variables, such as the password, in the
variables
tab, and reference it in the script.
Running the definition and check log events:
To learn more about JBoss EAP 6 CLI commands, please check this guide.
For detailed instructions on setting up a release definition, check out this guide.
Check out this guide for an overview of extensions of Visual Studio Team Services.
For detailed instructions on how to get and install extensions, check out this guide