Skip to content
Snippets Groups Projects
Commit 9be19c37 authored by L. Ellenbeck's avatar L. Ellenbeck
Browse files

BUILD: added missing push to git coscine/issues#1414

parent 334b6aaf
No related tags found
1 merge request!11Product/1414 fh privileges
Pipeline #461824 passed
......@@ -8,6 +8,7 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
// Commandline arguments
var target = Argument("target", "Default");
......@@ -17,6 +18,9 @@ var version = Argument("nugetVersion", "");
var gitlabProjectPath = Argument("gitlabProjectPath", "");
var gitlabProjectId = Argument("gitlabProjectId", "");
var gitlabToken = Argument("gitlabToken", "");
var branch = Argument("branch", "");
var gitAuthorEmail = Argument("gitAuthorEmail", "");
var gitAuthorName = Argument("gitAuthorName", "");
// Define directories
var projects = GetFiles("./**/*.csproj");
......@@ -334,6 +338,42 @@ Task("NugetPushLocal")
}
});
Task("PushToGit")
.Does(() =>{
if(FileExists($"{artifactsDir}/index.ttl"))
{
var client = new HttpClient();
var content = FileReadText($"{artifactsDir}/index.ttl");
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri("https://git.rwth-aachen.de/api/v4/projects/47542/repository/files/index.ttl"),
Headers =
{
{ "private-token", gitlabToken },
},
Content = new StringContent($"{{\"branch\": \"{branch}\", \"author_email\":\"{gitAuthorEmail}\", \"author_name\": \"{gitAuthorName}\", \"content\": \"{content.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\"", "\\\"")}\", \"commit_message\": \"update file\"}}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = client.SendAsync(request).Result)
{
var body = response.Content.ReadAsStringAsync().Result;
Information("IsSuccess: {0}", response.IsSuccessStatusCode);
Information("StatusCode: {0}", response.StatusCode);
Information("Response: {0}", response.Content.ReadAsStringAsync().Result);
response.EnsureSuccessStatusCode();
}
} else {
Information("No index ttl found. Nothing to do.");
}
});
Task("Prerelease")
.IsDependentOn("Build")
.IsDependentOn("CopyToArtifacts")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment