zdenko.s
zdenko.s

Reputation: 1032

AWS CodeBuild: Where is documented buildspec.yml multiline command script?

I have buildspec.yml with multiple commands in pre_build phase and more in build phase. When I specify commands as array items

  pre_build:
    commands:
      - $Env:TEST_SUBFOLDER='dev\';
      - Invoke-Expression('cmd /c set')

each command is executed in its own shell session. In above example TEST_SUBFOLDER environment variable is not set when invoking next command.
But if I specify commands as single item

  pre_build:
    commands:
      $Env:TEST_SUBFOLDER='dev\'; `
      Invoke-Expression('cmd /c set')

every command runs in same shell and TEST_SUBFOLDER environment variable is set. Where is this feature documented? I do not find any reference. SO question Variable mysteriously disappears? AWS CodeBuild sugests to use version 0.2 of buildspec. I am using version 0.2

Upvotes: 4

Views: 4890

Answers (1)

Victor Machado
Victor Machado

Reputation: 280

You can do a YAML block scalar syntax:

  pre_build:
    commands:
      - >-
        $Env:TEST_SUBFOLDER='dev\';
        Invoke-Expression('cmd /c set')

Upvotes: 8

Related Questions