I have added a task in Azure pipelines, the aim of task is to Enable WinRM on Remote Windows Servers.
Definition of task is below:
set -x
pwd
"cd $(System.DefaultWorkingDirectory)/_Terraform Build Phase/drop/terraform/scripts"
echo $/
sudo ./temp.sh
echo $?
I tried different variables but still no luck, the issue is, it is not able to change directory because of white space, I have double quotes around it but still not working, maybe I am not using the correct PreDefined variable?
Error message is as below:
2019-02-25T23:39:09.5826778Z ==============================================================================
2019-02-25T23:39:09.5826827Z Task : Command Line
2019-02-25T23:39:09.5826855Z Description : Run a command line script using cmd.exe on Windows and bash on macOS and Linux.
2019-02-25T23:39:09.5826885Z Version : 2.146.1
2019-02-25T23:39:09.5827075Z Author : Microsoft Corporation
2019-02-25T23:39:09.5827104Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
2019-02-25T23:39:09.5827131Z ==============================================================================
2019-02-25T23:39:09.7013466Z Generating script.
2019-02-25T23:39:09.7057060Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/69f83a50-dbda-4ddc-a5ac-d658cebf6030.sh
2019-02-25T23:39:09.7110679Z /home/vsts/work/r1/a
2019-02-25T23:39:09.7110949Z $/
2019-02-25T23:39:09.7115232Z + pwd
2019-02-25T23:39:09.7115916Z + 'cd /home/vsts/work/r1/a/_Terraform Build Phase/drop/terraform/scripts'
2019-02-25T23:39:09.7116546Z /home/vsts/work/_temp/69f83a50-dbda-4ddc-a5ac-d658cebf6030.sh: line 3: cd /home/vsts/work/r1/a/_Terraform Build Phase/drop/terraform/scripts: No such file or directory
2019-02-25T23:39:09.7117181Z + echo '$/'
2019-02-25T23:39:09.7117272Z + sudo ./temp.sh
2019-02-25T23:39:09.9383963Z sudo: ./temp.sh: command not found
2019-02-25T23:39:09.9385705Z + echo 1
2019-02-25T23:39:09.9387433Z 1
2019-02-25T23:39:09.9478312Z ##[section]Finishing: Enable WinRM
Have a look at the output below, not sure why it cannot excute?
2019-02-26T03:47:57.4977014Z ==============================================================================
2019-02-26T03:47:57.4977119Z Task : Command Line
2019-02-26T03:47:57.4977157Z Description : Run a command line script using cmd.exe on Windows and bash on macOS and Linux.
2019-02-26T03:47:57.4977195Z Version : 2.146.1
2019-02-26T03:47:57.4977413Z Author : Microsoft Corporation
2019-02-26T03:47:57.4977452Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
2019-02-26T03:47:57.4977490Z ==============================================================================
2019-02-26T03:47:57.6351017Z Generating script.
2019-02-26T03:47:57.6400544Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/d66aeba8-bdab-42b1-8988-cb139d4169a9.sh
2019-02-26T03:47:57.6466344Z /home/vsts/work/r1/a
2019-02-26T03:47:57.6466863Z $
2019-02-26T03:47:57.6474398Z + pwd
2019-02-26T03:47:57.6475184Z + cd '/home/vsts/work/r1/a/_Terraform Build Phase/drop/terraform/scripts/'
2019-02-26T03:47:57.6475966Z + echo '$'
2019-02-26T03:47:57.6476271Z + ls
2019-02-26T03:47:57.6476447Z azure_rm.py
2019-02-26T03:47:57.6476490Z InstallWinRM.sh
2019-02-26T03:47:57.6476558Z temp.sh
2019-02-26T03:47:57.6476708Z 0
2019-02-26T03:47:57.6476917Z + echo 0
2019-02-26T03:47:57.6476972Z + sudo ./temp.sh
2019-02-26T03:47:57.9981782Z sudo: ./temp.sh: command not found
2019-02-26T03:47:58.0025055Z + echo 1
2019-02-26T03:47:58.0025466Z 1
2019-02-26T03:47:58.0111749Z ##[section]Finishing: Enable WinRM
I have added double quotes but still not working?
"cd path"tries to execute the stringcd pathas a command, which of course is invalid. You wantcd "path"to run the commandcdwith the stringpathas its quoted argument. Voting to close as trivial typo.