I want to use a variable in my PowerShell build step inside a Jenkins Freestyle Job to trigger another job.
Therefore I need it as environment variable. This tutorial shows that I have to create the env.properties file which can be used. But I am not able to create one inside my script. There is this part:
Write-Host "TEST1"
"CPName_VAR=$projectCP" | Out-File env.properties -Encoding ASCII
Write-Host "TEST2"
The console prints out TEST1 and TEST2, but the creation of the file seems to get bypassed. Is there something wrong?
I also tried:
Write-Host $projectCP > env.properties
There is no error. But the envinject plugin (which I use to inject parameters from the properties file) throws an error at the end of the job because "there is no such file".
If I execute the command directly in my PowerShell IDE everything works fine and the properties file gets created in my home directory.
-VerbosetoOut-File. Also check$Error. Beforehand callingOut-Filewith-Verboseperform$Error.Clear(). Maybe you'll some extra information ...