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
preguntada hace 2 años1362 visualizaciones
1 Respuesta
0
Respuesta aceptada

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
respondido hace 2 años
profile picture
EXPERTO
revisado hace 6 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas