tag:help.appveyor.com,2012-11-13:/discussions/problems/3912-publishing-to-bintray-from-appveyorAppVeyor: Discussion 2018-08-25T02:03:14Ztag:help.appveyor.com,2012-11-13:Comment/388099042015-12-31T18:33:34Z2015-12-31T18:33:35ZPublishing to bintray from appveyor <div><p>Hello,</p>
<p>I have problem publishing generated installers to bintray.</p>
<p>The following code produces <code>Invoke-RestMethod : The remote
server returned an error: (401) Unauthorized.</code></p>
<pre>
<code>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</code>
</pre>
<p>But when I do it manually by RDP and PowerShell and by replacing
<code>$BINTRAYKEY</code> by its real value, it works.</p>
<p>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 ?</p>
<p>Regards,</p>
<p>Gaël</p></div>Gaëltag:help.appveyor.com,2012-11-13:Comment/388099042015-12-31T18:41:05Z2015-12-31T18:41:05ZPublishing to bintray from appveyor <div><p>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.</p>
<p>-Feodor</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/388099042016-01-01T00:03:37Z2016-01-01T00:03:39ZPublishing to bintray from appveyor <div><p>I found the solution just after asking: Contrary to bash, in
PowerShell, environment variables must be preceded by 'Env:'.
Writing:</p>
<pre>
<code> - ps: $pass = "$Env:BINTRAYKEY"</code>
</pre>
<p>made it work.</p>
<p>Thanks and happy new year !</p>
<p>Gaël</p></div>Gaëltag:help.appveyor.com,2012-11-13:Comment/388099042016-01-01T00:07:13Z2016-01-01T00:07:13ZPublishing to bintray from appveyor <div><p>Thanks for the update and Happy New Year!</p></div>Feodor Fitsner