How to override environment variables from REST API when using build matrix

TAMAGAWA Hiroko's Avatar

TAMAGAWA Hiroko

09 Jun, 2020 04:06 AM

When using build matrix, I cannot find out how to override the environment variables from REST API.

My small example is in this repository
https://github.com/nkns165/appveyor-test

Assume I'm kicking the build with a command like this. I'm trying to overwrite the variable "VAR1".

curl -H "Authorization: Bearer $APPVEYOR_TOKEN" -H "Content-Type: application/json" https://ci.appveyor.com/api/account/nkns165/builds -X POST -d "{
  \"accountName\": \"nkns165\", 
  \"projectSlug\": \"appveyor-test\", 
  \"branch\": \"master\", 
  \"environmentVariables\": {
    \"VAR1\": \"Value2\"
  }
}"

Success without build matrix

https://ci.appveyor.com/project/nkns165/appveyor-test/builds/33401661

  • There are two images used, but there is no matrix
  • The script output the overridden value "Value2"

Failure with build matrix

https://ci.appveyor.com/project/nkns165/appveyor-test/builds/33401705

  • Each image's build script is defined in matrix
  • The script output the default value "Value1" instead of expected value "Value2"

Is there any way to override the values by REST API parameters?

  1. Support Staff 1 Posted by Feodor Fitsner on 09 Jun, 2020 04:30 AM

    Feodor Fitsner's Avatar

    Removing VAR1 definition from the config should do the trick:

    image:
      - macos
      - macos-mojave
    
    build_script:
      - ps: echo "VAR1 = $env:VAR1"
    
    for:
    -
      matrix:
        only:
          - image: macos
    
      build_script:
        - ps: echo "VAR1 for catalina = $env:VAR1"
    
    -
      matrix:
        only:
          - image: macos-mojave
      
      build_script:
        - ps: echo "VAR1 for mojave = $env:VAR1"
    
  2. 2 Posted by TAMAGAWA Hiroko on 09 Jun, 2020 05:22 AM

    TAMAGAWA Hiroko's Avatar

    Confirmed, thanks.

    Umm, then we have to add some merging logic if we'd like to also have default values.
    OK, I think we can do it

  3. TAMAGAWA Hiroko closed this discussion on 09 Jun, 2020 05:23 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac