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
gefragt vor 2 Jahren1361 Aufrufe
1 Antwort
0
Akzeptierte Antwort

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
beantwortet vor 2 Jahren
profile picture
EXPERTE
überprüft vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen