Reputation: 64
I'm developing a plugin for TeamCity and I'm trying to find a way to update an environment variable from my build step.
I created an env variable manually in my build configurations (under "Parameters"). When I debug the plugin, I can see that my env variable is there, but I can't assign a new value to it.
This is how I tried to assign a value to it:
buildRunnerContext.getBuild().addSharedEnvironmentVariable("mySystemProperty", "Some value");
I also tried:
buildRunnerContext.addEnvironmentVariable("mySystemProperty", "Some value");
None of the above worked.
Using this, I can get the env variable that I created in TC:
BuildParametersMap envs = buildRunnerContext.getBuild().getSharedBuildParameters();
So, is there a way to do it? Basically, I'm trying to return some value from my build step and store it in env variable so that it can be used in other steps. Other suggestions are welcome as well :)
Upvotes: 4
Views: 5437
Reputation: 405
In a Command Line Runner Type, I was able to do it using echo command as :-
echo "##teamcity[setParameter name='env.Id' value='test']"
In next test step, I was able to fetch the same value.
Upvotes: 4