Skip to content
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

node-jenkins doesn't play well with folders plugin #17

Open
ghost opened this issue Sep 3, 2014 · 1 comment
Open

node-jenkins doesn't play well with folders plugin #17

ghost opened this issue Sep 3, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 3, 2014

In my jenkins installation at work because have many products we have regrouped jobs with folders plugin to make sure we do not end up with a huge mess. When calling the jenkins api for the list of all jobs on the server all we get is the list of folders not the job that are contained in them. is there a way around that?

@signus
Copy link

signus commented Feb 23, 2016

It's not easy, but it can certainly be done. Unfortunately the Jenkins API doesn't play nicely with folders either as it causes the URL to become sets of nested name/job/name/job/name/job items.

In my testing situation I was able to do this using async and I filter on a particular name. You can use this for particular qualifiers or use non-matching criteria. For example - all of my jobs have numbers in them, whereas the folders do not. However in job_info folders are still classified as a job. Here I just do a quick test with the nested names.

jenkins.job_info('Folder1', function(err, job) {
    if (err) throw err;

    async.forEach(job.jobs, function(item, callback) {
        if (item.name.match(/Folder2/g)) {
            jenkins.job_info('Folder1/job/' + item.name, function (ierr, intjob) {
                if (ierr) throw ierr;

                console.log(intjob);
            });
        }
    }, function (aerr) {
        throw aerr;
    });
});

Using this I see the jobs within a folder, and you can drill down further from there. Also make note that you can use the primaryView field to know the path of set of jobs you're querying.

It would certainly be nice to see better support for nested jobs/folders, for sure. However as messy as this is - I hope this helps you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant