简体   繁体   中英

Run aws cli command in CodeBuild with environment variable substituion

I am trying to run an aws cli command at the end of a CodeBuild from the buildspec.yml.

The container/image is "aws/codebuild/amazonlinux2-x86_64-standard:1.0"

I have an environment variable of $Branch (currently set to 'master')

and I want to run the command "aws codepipeline start-pipeline-execution --name bbentityinterface-master-Pipeline"

I have tried "aws codepipeline start-pipeline-execution --name $(bbentityinterface-$Branch-Pipeline)" and "aws codepipeline start-pipeline-execution --name bbentityinterface-$Branch-Pipeline"

and both fail.

"aws codepipeline start-pipeline-execution --name $(bbentityinterface-$Branch-Pipeline)" fails as below (from the log):

How can I properly construct this line to execute the command?

Running command aws codepipeline start-pipeline-execution --name $(bbentityinterface-$Branch-Pipeline) /codebuild/output/tmp/script.sh: line 4: bbentityinterface-master-Pipeline: command not found usage: aws [options] [ ...] [parameters] To see help text, you can run:

aws help aws help aws help aws: error: argument --name: expected one argument

[Container] 2020/01/08 15:46:40 Command did not exit successfully aws codepipeline start-pipeline-execution --name $(bbentityinterface-$Branch-Pipeline) exit status 2

Figured it out...

eval "aws codepipeline start-pipeline-execution --name bbentityinterface-$Branch

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM