0

I created a pipeline in Jenkins where I am passing AWS CLI commnads to start and stop windows services. below is my command commandId=$(aws ssm send-command --document-name "AWS-RunPowerShellScript" --instance-ids "$id1" --parameters commands='Get-Service -Name User Profile Service' --timeout-seconds 600 --region $Region --query "Command.CommandId" --output text)

when i am running the above command,getting the below error Error parsing parameter '--parameters': Expected: ',', received: '"' for input:

I think spaces in my service name causing the issue. I tried with double quotes but not working.

Please suggest how to resolve this

ramu246
  • 51
  • 1
  • 8
  • Is your `Jenkins slave` linux or windows? – mdabdullah Oct 04 '20 at 08:03
  • its windows.... – ramu246 Oct 05 '20 at 08:46
  • Please paste complete pipeline script to test in my local. – mdabdullah Oct 06 '20 at 18:04
  • pipeline { agent any stages { stage('service status') { steps{ script { // Assuing roles commands } script { sh ''' instanceId= Region= commandId=$(aws ssm send-command --document-name "AWS-RunPowerShellScript" --instance-ids "$id1" --parameters commands='Get-Service -Name User Profile Service' --timeout-seconds 600 --region $Region --query "Command.CommandId" --output text) } } } } } – ramu246 Oct 07 '20 at 12:47
  • Hello @mdabdullah, please let me know if you find any solution – ramu246 Oct 12 '20 at 12:54
  • I dont have the setup to try this, but I suspect we cannot use `sh` inside a windows slave to run shell commands. You can convert it into `.bat` and run it as `Windows Batch Command`. Please refer to this: https://stackoverflow.com/questions/41595897/jenkins-pipeline-cannot-execute-sh-command-file-in-a-windows-slave – mdabdullah Oct 17 '20 at 14:40

0 Answers0