Skip to content

Commit f0c1981

Browse files
author
Gary Ewan Park
committed
(Correction) Changed to using REST API
- As per discussion here: #262 - Changed to use the AppVeyor REST API SetVariable method, instead of setting an Environment Variable
1 parent fe947ad commit f0c1981

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

GitVersionCore/BuildServers/AppVeyor.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,19 @@ public override string GenerateSetVersionMessage(string versionToUseForBuildNumb
6161

6262
public override string[] GenerateSetParameterMessage(string name, string value)
6363
{
64-
Environment.SetEnvironmentVariable("GitVersion." + name, value);
64+
using (var wc = new WebClient())
65+
{
66+
wc.BaseAddress = Environment.GetEnvironmentVariable("APPVEYOR_API_URL");
67+
wc.Headers["Accept"] = "application/json";
68+
wc.Headers["Content-type"] = "application/json";
69+
70+
var body = string.Format("{{ \"name\": \"GitVersion_{0}\", \"value\": \"{1}\" }}", name, value);
71+
wc.UploadData("api/build/variables", "POST", Encoding.UTF8.GetBytes(body));
72+
}
6573

6674
return new[]
6775
{
68-
string.Format("Adding Environment Variable. name='GitVersion.{0}' value='{1}']", name, value)
76+
string.Format("Adding Environment Variable. name='GitVersion_{0}' value='{1}']", name, value)
6977
};
7078
}
7179
}

0 commit comments

Comments
 (0)