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
    
Jess
질문됨 2년 전1361회 조회
1개 답변
0
수락된 답변

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

Jess
답변함 2년 전
profile picture
전문가
검토됨 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠