Publishing to bintray from appveyor

Gaël's Avatar

Gaël

31 Dec, 2015 06:33 PM

Hello,

I have problem publishing generated installers to bintray.

The following code produces Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

environment: 
  BINTRAYKEY:
    secure: SF9KK/1ShDAudlHJFsZro1MQOaYqjJ0Hb2mbJEvFyxPCLHtevjyxuLT1IrsSmE1o

on_success:
  - ps: $user = "kleag"
  - ps: $pass = "$BINTRAYKEY"
  - ps: $pair = "${user}:${pass}"
  - ps: $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
  - ps: $base64 = [System.Convert]::ToBase64String($bytes)
  - ps: $basicAuthValue = "Basic $base64"
  - ps: $headers = @{ Authorization = $basicAuthValue }
  - ps: Invoke-RestMethod  -Method PUT -Headers $headers -uri https://api.bintray.com/content/kleag/windows64/lima/$APPVEYOR_BUILD_NUMBER/$APPVEYOR_BUILD_NUMBER/limacommon-2.1.-win64.exe?publish=1 -Infile C:/b/lima_common/src/lima_common-build/limacommon-2.1.-win64.exe

But when I do it manually by RDP and PowerShell and by replacing $BINTRAYKEY by its real value, it works.

So, it seems that the $BINTRAYKEY secured variable is not replaced by its real value. Do I have something to do to make the replacement work ?

Regards,

Gaël

  1. Support Staff 1 Posted by Feodor Fitsner on 31 Dec, 2015 06:41 PM

    Feodor Fitsner's Avatar

    If it's PR build then secure variables are not set (for security reasons). However, you can allow secure variables for PR builds of private repos.

    -Feodor

  2. 2 Posted by Gaël on 01 Jan, 2016 12:03 AM

    Gaël's Avatar

    I found the solution just after asking: Contrary to bash, in PowerShell, environment variables must be preceded by 'Env:'. Writing:

      - ps: $pass = "$Env:BINTRAYKEY"
    

    made it work.

    Thanks and happy new year !

    Gaël

  3. Support Staff 3 Posted by Feodor Fitsner on 01 Jan, 2016 12:07 AM

    Feodor Fitsner's Avatar

    Thanks for the update and Happy New Year!

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