cliffano / nestor

Jenkins CLI and node.js client
http://blog.cliffano.com/tag/nestor/
MIT License
182 stars 27 forks source link

Support multiple jenkins instances #31

Closed kelveden closed 9 years ago

kelveden commented 9 years ago

In the environment I work in we have multiple jenkins instances. It would be nice to be able to call something like nestor build myjob and it would read a config file and would automatically know which jenkins instance to interrogate.

I was thinking of a config file that mapped jenkins urls to an array of regexes - something like this:

[
  {
    "url": "http://my.jenkins.box1",
    "jobs": [ "someapp-.+", "anotherapp-.+" ]
  },
  {
    "url": "http://my.jenkins.box2",
    "jobs": [ "yetanotherapp-.+" ]
  }
]

(The config file would be optional - if it's missing then obviously the above functionality won't work but the rest of nestor would.) What do you think? It's something I'll try and have a go at myself if it's of interest.

kelveden commented 9 years ago

Hmm, after further thought I'm not so sure that this is a good idea. It works well for something like the "build" command but for other commands like "copy", "executor" etc. it could get confusing.

I'm thinking that some sort of wrapper to nestor would suit better. I'll add a link to what I come up with (if it works).

cliffano commented 9 years ago

I'm still in the middle of refactoring Nestor codebase (separating CLI, notifiers, etc away from the core), so at this point I'd like to keep the configuration setup unchanged at least until the refactoring is done.

The example code snippet that you provided above seems to be geared towards job-related tasks, but Nestor is geared towards a Jenkins instance, so yep like you said it won't translate to all other commands.

If your goal is to execute a command across multiple instances and multiple jobs, the simplest I can think off is a script with piped sed, awk, grep, and xargs. If you want something more readable, perhaps a tool like Ansible would be handy. Another idea is to have an instance switch a la https://www.npmjs.org/package/npmrc .

kelveden commented 9 years ago

@cliffano Thanks for getting back. Yes, a wrapper script of some sort I think is the way to go. I think polluting nestor itself with such functionality would distract from the focus of the application.