2

I have installed AWS CLI on my windows slave in Jenkins. To verify the same, I run the following command in the command line of the windows machine and get this as the output

C:> aws --version
aws-cli/1.11.122 Python/2.7.9 Windows/2008ServerR2 botocore/1.5.85

I am running an aws cli command in the execute windows batch command in the jenkins job and the job is failing for the following reason

C:\Users\ADMINI~1\AppData\Local\Temp\2\hudson1929374596375903011.sh: line 6: 
aws: command not found
Build step 'Execute shell' marked build as failure

The aws command I am running is

aws cloudformation validate-template --template-body file://file1.json

I also checked the PATH variable on the windows machine and it contains AWSCLI path.

My goal is to run AWS CLI command via Jenkins job. Can somebody help me with this?

shubhamagiwal92
  • 1,362
  • 4
  • 25
  • 47
  • You may need to explicitly set your jenkins PATH. See https://stackoverflow.com/questions/36473479/how-to-set-the-path-environment-variable-in-jenkins-configuration-on-windows – Rodrigo Murillo Jul 20 '17 at 18:10

1 Answers1

2

It's possible that Jenkins has a different %PATH% than when you are logged in.

Try finding your path via jenkins. Create a job and in the script that runs echo out your %PATH% to see what jenkins' thinks your path is.

You can modify Jenkins' environment variables, including %PATH%, see https://stackoverflow.com/a/5819768/8207662

Hammett
  • 375
  • 3
  • 11
  • Yes you were right. AWS CLI was not present in the %PATH% Variable. Just add the following link in your answer https://stackoverflow.com/questions/5818403/jenkins-hudson-environment-variables So that I can accept the same – shubhamagiwal92 Jul 20 '17 at 18:31