Azure pipeline SSH Remote Command failed with docker compose

Mohammad Moussavi 1 Reputation point
2021-07-26T12:32:02.073+00:00

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 App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
Developer technologies .NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2021-07-27T19:19:01.083+00:00

    Hi @Mohammad Moussavi ,

    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://learn.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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.