-
Notifications
You must be signed in to change notification settings - Fork 37
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
Handle complex job names #19
Comments
I can't seem to get child jobs from Jobs, so this library doesn't really work for me. Or is there something i misunderstand? |
The Jenkins REST API does return the child jobs. If this library isn't exposing that we should be able to modify it simply enough. |
I ended up doing my own custom API manipulation for my own needs and got ALL jobs like this. private async Task<IEnumerable<string>> GetJobs(HttpClient client, Uri url)
{
var list = new List<string>();
var xml = XDocument.Parse(await client.GetStringAsync(new Uri(url, "api/xml")));
var jobs = xml.XPathSelectElements("//job/url").Select(x => x.Value).ToList();
if (jobs.Any())
{
list.AddRange(jobs);
var jobTasks = jobs.Select(async job => await GetJobs(client, new Uri(job)));
var results = await Task.WhenAll(jobTasks.ToArray());
jobs.AddRange(results.SelectMany(x => x));
}
return jobs;
} |
@pjmagee I had to look at this twice to see what you were actually doing, I didn't catch the inner job lookup on first pass. The first portion of what your doing already exists in the
Unfortunately there is currently no way to lookup the details for that job, since the @petelopez Sorry, to be honest I don't even use Jenkins anymore so this project has become secondary. With the growing number of user for this library though, I'm trying to come back and maintain requests. I think this is a good request and should be implemented, but it may take me a bit of time to setup Jenkins again and create a nested job layout for testing. Based on your example though, it looks like a user should be able to pass "path/to/folder/finalName" as the jobName argument, and the library can just split on |
So... what do I pass in as the "job name" when I have a child job? Passing in the URL doesn't work Edit: nevermind, figured it out: the syntax is SomeJob/job/SomeChildJob |
Jenkins api follows the pattern
{baseUrl}/job/{JOB_NAME}
. However, if we have jobs nested in folders the job the pattern is{baseUrl}/job/{path}/job/{to}/job/{folder}job/{finalName}
. In the UI, Jenkins shows this job name aspath/to/folder/finalName
.On my first attempt at consuming the library I passed in the job name as shown in the UI. Perhaps you can consider expanding it so that either works or make it clearer which format is expected.
The text was updated successfully, but these errors were encountered: