Skip to content
Advertisement

Using VSTS Release to Unzip FIles on Linux VM

I am trying to use VSTS to deploy a zip file to a Linux VM in Azure. I am using an SSH task to run the command:

sudo unzip -ju /home/$USER/release/deployfile-1.6.zip "*.war" -d "/opt/tomee/webapps/"

That command works. I don’t want to change the filename each time it changes, though. I tried using a variable name:

sudo unzip -ju /home/$USER/release/$filename "*.war" -d "/opt/tomee/webapps/"

And I tried using a wildcard:

cd "/home/$USER/release/"
sudo unzip -ju '*.zip' "*.war" -d "/opt/tomee/webapps/"

(the above is supposed to be star.zip and star.war) Neither of those worked, and having little familiarity with Linux, I haven’t been able to figure out a syntax that works.

Could someone please advise? Thank you.

Advertisement

Answer

Based on @JNevill comments, I made another attempt at using a variable for the filename. I also changed the u parameter to an o to automatically overwrite files. The final command syntax is:

sudo unzip -jo "/home/$USER/release/$(filename)" "*.war" -d "/opt/tomee/webapps/"

When the command is executed on the remote VM it becomes:

sudo unzip -jo "/home/$USER/release/deployfile-1.6.zip" "*.war" -d "/opt/tomee/webapps/"

The war files were successfully deployed to the VM.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement