Environment variable with array values

Just wanted to migrate an existing plugin of mine and move the setting variables into a environment key.

It seems like there is no way to use arrays in the environment section, or did I messed up the yaml format? -

YAML for plugin

- name: "PRComment"
  image: *********.net/drone-prcomment:latest
  settings:
    GITEA_TOKEN:
      from_secret: GITEA_TOKEN
    VERBOSEMODE: true
    CUSTOM_PIPELINE_STATE: true
    READ_FILES:
    - build/FileLinter-Results.log
    - build/ScriptAnalyzer-Results.log
    - build/Pester-Results.log
    - build/FileLinter.log
  when:
    event:
      include:
        - pull_request

YAML for environment

- name: "PWSH PRComment"
    image: **********.net/drone-psbuildimage:latest
    failure: ignore
    commands:
      - pwsh -NonInteractive -c "& {Import-Module './src/DroneIO.psd1'; Send-PRComment}"
    environment:
      GITEA_TOKEN:
        from_secret: GITEA_TOKEN
      CUSTOM_PIPELINE_STATE: true
      LOG_FILES:
      - "build/FileLinter-Results.log"
      - "build/ScriptAnalyzer-Results.log"
      - "build/Pester-Results.log"
    when:
      event:
        include:
          - pull_request

image

The error points to the line LOG_FILES. I’ve already tried to indent the array like this:

LOG_FILES:
  - "build/FileLinter-Results.log"
  - "build/ScriptAnalyzer-Results.log"
  - "build/Pester-Results.log"

Both variants work if used in a settings block but not as environment variables. I really can’t see what I’m missing here :fire_extinguisher:

Both variants work if used in a settings block but not as environment variables. I really can’t see what I’m missing here

The settings block is free form and supports arbitrary, nested structures. The environment block is a map[string]string data structure, which means it accepts key value pairs only, where both the key and value are strings.

Thanks. I wasn’t quite sure, If I already tried this in other pipelines. So couldn’t tell, if I missed something, or it just simply works as designed.

Anyway, I reworked my code to accept a simple regex instead of a file list :slight_smile:

Thanks for the help!

My drone plugin for for gitea works now :wink: