Does BinTray provider respect any environment variables?

lenox.joseph's Avatar

lenox.joseph

22 Aug, 2016 08:58 PM

I'd like to alter which BinTray package I deploy to based on the branch being compiled. Can I add a pre-deployment script to set a specific environment variable or should I just go with a full custom PS script and bypass the existing provider?

  1. Support Staff 1 Posted by Feodor Fitsner on 22 Aug, 2016 09:09 PM

    Feodor Fitsner's Avatar

    Yes, custom environment variables should be respected there.

  2. 2 Posted by lenox.joseph on 23 Aug, 2016 12:16 AM

    lenox.joseph's Avatar

    Is there a list of what gets used by the provider, or is it the straight
    configuration options?

  3. Support Staff 3 Posted by Feodor Fitsner on 23 Aug, 2016 12:35 AM

    Feodor Fitsner's Avatar

    This is the list of system environment variables: https://www.appveyor.com/docs/environment-variables/

    You can use any environment variable though like this: https://www.appveyor.com/docs/deployment/#environment-variables-in-provider-settings

    -Feodor Fitsner, AppVeyor

  4. 4 Posted by lenox.joseph on 23 Aug, 2016 02:28 AM

    lenox.joseph's Avatar

    If I define a new environment variable in the pre-deployment script, will
    it be used during deployment?

    --Joseph Lenox

  5. Support Staff 5 Posted by Feodor Fitsner on 23 Aug, 2016 02:29 AM

    Feodor Fitsner's Avatar

    It should though I can say for sure if see your appveyor.yml

    -Feodor Fitsner, AppVeyor

  6. 6 Posted by lenox.joseph on 23 Aug, 2016 03:21 PM

    lenox.joseph's Avatar

    Apparently not, I had set $packagevar in the configuration and created the
    environment variable using the following script:

    [Environment]::SetEnvironmentVariable("packagevar", "Slic3r_Branches",
    "User")
    If ($APPVEYOR_REPO_BRANCH -like "master")
    {[Environment]::SetEnvironmentVariable("packagevar", "slic3r_dev", "User")}

    Uploading "slic3r-3440-draft-shield--566bbbd.zip" to BinTray as
    lordofhyphens/Slic3r/$packagevar/1.3.0-3440-draft-shield-165/slic3r-3440-draft-shield--566bbbd.zip

    --Joseph Lenox

  7. Support Staff 7 Posted by Feodor Fitsner on 23 Aug, 2016 04:07 PM

    Feodor Fitsner's Avatar

    Correct code might be:

    If ($env:APPVEYOR_REPO_BRANCH -eq "master") { $env:packagevar = 'slic3r_dev' } else { $env:packagevar = 'Slic3r_Branches' }
    
  8. 8 Posted by fredrik.averpil on 23 Aug, 2016 08:07 PM

    fredrik.averpil's Avatar

    Having this very same issue. Posted about it here: http://help.appveyor.com/discussions/questions/2585-how-to-use-vari...

  9. 9 Posted by fredrik.averpil on 23 Aug, 2016 08:39 PM

    fredrik.averpil's Avatar

    I solved it:

    after_build:
      - $env:SOMETHING_UNIQUE = "MyPackageName"
    
    deploy:
      - provider: BinTray
        package: $(SOMETHING_UNIQUE)
    
  10. 10 Posted by Ilya Finkelshte... on 24 Aug, 2016 12:26 AM

    Ilya Finkelshteyn's Avatar

    Right, this is expected, because build execution is not single PowerShell script, and variables are not preserved between separate PowerShell statements, while environment variables do exist till the end of build job.

    --ilya,

  11. 11 Posted by fredrik.averpil on 24 Aug, 2016 06:05 AM

    fredrik.averpil's Avatar

    Right, this is expected, because build execution is not single PowerShell script, and variables are not preserved between separate PowerShell statements, while environment variables do exist till the end of build job.

    It took some time to figure this out, as I wasn't able to call that environment variable like $env:SOMETHING_UNIQUE or $SOMETHING_UNIQUE. Instead I had to call it like $(SOMETHING_UNIQUE).

  12. 12 Posted by lenox.joseph on 24 Aug, 2016 07:51 AM

    lenox.joseph's Avatar

    Thanks, that works. Maybe this should be added to the main support
    documents?

  13. 13 Posted by fredrik.averpil on 24 Aug, 2016 08:11 AM

    fredrik.averpil's Avatar

    Thanks, that works. Maybe this should be added to the main support documents?

    +1

  14. Support Staff 14 Posted by Feodor Fitsner on 24 Aug, 2016 08:38 PM

    Feodor Fitsner's Avatar

    There is a note about that: https://www.appveyor.com/docs/deployment/#environment-variables-in-...

    You may contribute to the documentation if you feel something's missing.

  15. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:08 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