question

MohammadMoussavi-2858 avatar image
0 Votes"
MohammadMoussavi-2858 asked ryanchill edited

Azure pipeline SSH Remote Command failed with docker compose

Hi, I have 2 questions.
1- In SSH remote command I have to put all commands in one line with AND ( && ) them together, I don't know why is that. I can't make them separate one command per line or even separate them with ; When I put ; between commands the "cd" command won't work. This is all I want to do:

cd /opt/telbot
docker pull myprivate_docker_registery.com/my_app:version-$(Build.BuildId)
TAG=version-$(Build.BuildId) docker-compose up -d myservice

But I have to do this like this:

cd /opt/telbot && docker pull myprivate_docker_registery.com/my_app:version-$(Build.BuildId) && TAG=version-$(Build.BuildId) docker-compose up -d myservice

I guess it's something about "cd" command. It can't run the "cd" but the other commands runs fine.

2- The docker compose up -d command does the job fine but it returns error on Azure pipeline. It recreates the app container with new image and leaves the MySQL alone. But it causes failure on job.

117940-capture.png

What should I do for these 2 problems ?? Thank you so much, I'm pretty newbie in Azure DevOps.


azure-webappsdotnet-ad
capture.png (57.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered ryanchill edited

Hi @MohammadMoussavi-2858,

Questions related to DevOps is better asked over on https://developercommunity.visualstudio.com/search?space=21. Having said that, you should be able to use a ; rather than && to chain commands together as explained in https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/ssh?view=azure-devops#arguments. You may also be better off having the task use a script file to execute the commands you need.

With regards to the error messages you're seeing, I would run the task with verbose option enabled to get additional information. The first two error messages don't seem like true error messages to me and the last could be appearing because the first two are being marked as errors.

If your app doesn't deploy or startup without issue, indicate the error messages down below.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.