Environment variables set in init script
Are environment variables set in an init script not persisted into the build phase?
I have an initialization script that relies on encrypted variables, available in the init phase, and needs to set additional variables, but those are not carried into the build phase. Is this expected?
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

Support Staff 1 Posted by Feodor Fitsner on 27 May, 2016 06:12 PM
They should be available during the build. How do you set them?
2 Posted by Fabio Cavalcant... on 27 May, 2016 06:22 PM
Saw the same behavior setting them in a couple different ways from PS (e.g. $env:test="test" and [Environment]::SetEnvironmentVariable("test","test" ) )
Support Staff 3 Posted by Feodor Fitsner on 27 May, 2016 06:28 PM
That should work. Can you do a repro in a public repository with statements settings vars and using them?
4 Posted by Fabio Cavalcant... on 27 May, 2016 06:34 PM
Interesting, it was helpful to get confirmation that it should work. I went back to another project and got it working there, so I think I missed something on the original project.
I'll take a look and post an update...
5 Posted by Fabio Cavalcant... on 27 May, 2016 07:54 PM
Perhaps I'm operating under a false assumption...
I know encrypted variables are not available in the build phase in case of PRs, but is that also true for the init phase?
Support Staff 6 Posted by Feodor Fitsner on 27 May, 2016 08:33 PM
Yes, secure variables are not available for the entire PR build.
-Feodor
7 Posted by Fabio Cavalcant... on 27 May, 2016 10:17 PM
Ok... that took me down a different path and I'll be triggering builds using the API, but keep getting a 500 when trying to trigger a PR build.
I'm attaching the full Fiddler capture (with the token removed).
There isn't a lot of information to troubleshoot this... are there any logs or additional details I can look at?
8 Posted by Fabio Cavalcant... on 27 May, 2016 10:38 PM
Ah... adding the content-type to the request fixed the issue.
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:06 AM.