Windows exec runner environment variables

Not sure how I use environment variables

nothing seems to appear in %ENV_VAR% or ${ENV_VAR}

also how to i crash out when a command fails - the step passes even though final command failed

- name: certificates
  when:
    branch:
    - build-certificates
  environment:
    PASSPHRASE:
      from_secret: certificate-passphrase
    EXPORT_PASSPHRASE:
      from_secret: certificate-export-passphrase
  commands:
    - cd c:\users\administrator\documents\certs
    - echo "${EXPORT_PASSPHRASE}" > exx
    - certutil -delstore my XXX
    - certutil -delstore root "XXX"
    - certutil -addstore "Root" XXX.crt
    - certutil -p "${EXPORT_PASSPHRASE}" -importPFX XXX.pfx

Not sure how I use environment variables
nothing seems to appear in %ENV_VAR% or ${ENV_VAR}

The commands section is used to generate a powershell script which means you need to read environment variables using powershell syntax which looks something like $Env:ENV_VAR.

also how to i crash out when a command fails - the step passes even though final command failed

Drone adds $erroractionpreference = "stop" to the generated powershell script and also looks at the exit code returned from each command in your pipeline (syntax below) as described here. If the pipeline passes it would indicate a zero exit code was returned from the command.

if ($LastExitCode -gt 0) { exit $LastExitCode }
1 Like