By using AWS re:Post, you agree to the Terms of Use

read Pipeline source stage Output variables in BuildSpec

0

Hi Team,

In my Pipeline -> Execution History -> source

I have a section: Output variables

Key Value AuthorDate 2022-03-01T10:14:36Z BranchName main CommitId 9d1545410efdf085185cdfdfdbdfdce807e9a3dfd8dfd CommitMessage my commit message CommitterDate 2022-03-01T10:14:36Z RepositoryName myRepo_name

is it possible to read those Output variables in my BuildProject->BuildSpec as env variables? so I can use their values, especially the BranchName value.

Thank you!

  • I added in code Build => environment variables section an env var :

    BRANCH_NAME, #{SourceVariables.BranchName}, plaintext

    when I read it in code build I have an output string equals to "#{SourceVariables.BranchName}" instead of "main"

    Key                  Value
    AuthorDate	2022-03-01T10:14:36Z
    BranchName	main
    CommitId	9dd60sds2sdbe2085sd3ab5074csd7e9a3sd16
    CommitMessage	my commit message
    CommitterDate	2022-03-01T10:14:36Z
    RepositoryName	my-repo_name
    
1 Answer
0
Accepted Answer

I did those steps :

1 - Sign in to the AWS Management Console and open the CodePipeline console at http://console.aws.amazon.com/codesuite/codepipeline/home.

2 - Choose the pipeline => choose Edit. On the stage that contains your CodeBuild action, choose Edit stage.

3- Choose the icon to edit your CodeBuild action.

4 - On the Edit action page, under Environment variables, enter the following:

  • In Name, enter a name for your environment variable.

  • In Value, enter the variable syntax for your pipeline output variable: #{SourceVariables.BranchName}.

  • In Type, choose Plaintext.

then in code buildSpec you access the resolved value like $VAR_NAME

answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions