Environment variables set in init script

Fabio Cavalcante's Avatar

Fabio Cavalcante

27 May, 2016 06:06 PM

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?

  1. Support Staff 1 Posted by Feodor Fitsner on 27 May, 2016 06:12 PM

    Feodor Fitsner's Avatar

    They should be available during the build. How do you set them?

  2. 2 Posted by Fabio Cavalcant... on 27 May, 2016 06:22 PM

    Fabio Cavalcante's Avatar

    Saw the same behavior setting them in a couple different ways from PS (e.g. $env:test="test" and [Environment]::SetEnvironmentVariable("test","test" ) )

  3. Support Staff 3 Posted by Feodor Fitsner on 27 May, 2016 06:28 PM

    Feodor Fitsner's Avatar

    That should work. Can you do a repro in a public repository with statements settings vars and using them?

  4. 4 Posted by Fabio Cavalcant... on 27 May, 2016 06:34 PM

    Fabio Cavalcante's Avatar

    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. 5 Posted by Fabio Cavalcant... on 27 May, 2016 07:54 PM

    Fabio Cavalcante's Avatar

    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?

  6. Support Staff 6 Posted by Feodor Fitsner on 27 May, 2016 08:33 PM

    Feodor Fitsner's Avatar

    Yes, secure variables are not available for the entire PR build.

    -Feodor

  7. 7 Posted by Fabio Cavalcant... on 27 May, 2016 10:17 PM

    Fabio Cavalcante's Avatar

    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. 8 Posted by Fabio Cavalcant... on 27 May, 2016 10:38 PM

    Fabio Cavalcante's Avatar

    Ah... adding the content-type to the request fixed the issue.

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