Skip to content

Add Support for Jenkins Folder Jobs #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Jenkins.Net/Internal/Commands/ArtifactGetCommand.cs
Original file line number Diff line number Diff line change
@@ -23,7 +23,9 @@ public ArtifactGetCommand(IJenkinsContext context, string jobName, string buildN
throw new ArgumentException("'filename' cannot be empty!");

var urlFilename = filename.Replace('\\', '/');
Url = NetPath.Combine(context.BaseUrl, "job", jobName, buildNumber, "artifact", urlFilename);
var postfix = $"artifact/{urlFilename}";

Url = ConstructUrl(context.BaseUrl, jobName, buildNumber, postfix);
UserName = context.UserName;
Password = context.Password;
Crumb = context.Crumb;
2 changes: 1 addition & 1 deletion Jenkins.Net/Internal/Commands/BuildGetCommand.cs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ public BuildGetCommand(IJenkinsContext context, string jobName, string buildNumb
if (string.IsNullOrEmpty(buildNumber))
throw new ArgumentException("'buildNumber' cannot be empty!");

Url = NetPath.Combine(context.BaseUrl, "job", jobName, buildNumber, "api/xml");
Url = ConstructUrl(context.BaseUrl, jobName, buildNumber, "api/xml");
UserName = context.UserName;
Password = context.Password;
Crumb = context.Crumb;
21 changes: 21 additions & 0 deletions Jenkins.Net/Internal/JenkinsHttpCommand.cs
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using System.Collections.Generic;


#if NET_ASYNC
using System.Threading;
@@ -154,5 +156,24 @@ private static string RemoveXmlDeclaration(string xml)
const string pattern = @"<\?xml[^\>]*\?>";
return Regex.Replace(xml, pattern, string.Empty);
}

internal string ConstructUrl(string baseUrl, string jobName, string buildNumber,string postfix)
{
var jobParts = jobName.Split(['/'], StringSplitOptions.RemoveEmptyEntries);
var urlParts = new List<string> { baseUrl };

foreach (var part in jobParts)
{
urlParts.Add("job");
urlParts.Add(part);
}

urlParts.Add(buildNumber);
urlParts.Add(postfix);

return NetPath.Combine(urlParts.ToArray());
}


}
}