cliffano / nestor

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

TypeError: Object #<Jenkins> has no method 'last' #27

Closed catchharish closed 9 years ago

catchharish commented 10 years ago

Hello there,

I am stuck with a weird problem. While using nestor, I am unable to execute the method 'last' and I keep getting the error mentioned here..

TypeError: Object # has no method 'last'

What may I be doing wrong here, or is it a bug of some sort with the nestor implementation I am attaching the code snippet here..

var nestor = new (require('nestor'))('credentials@jenkins_ip:8080'); nestor.last(jenkinsJobName,function(err, data){ })

catchharish commented 10 years ago

I just noticed that there is a difference between the file versions available on git repo vs on npm.. is it intentional?.. The jenkins.js file in git has the 'last' method while the one obtained when i do an npm install nestor does not have the method in jenkins.js..

cliffano commented 10 years ago

@catchharish Yes, they are different.

Nestor is currently in the middle of some refactorings and new features like 'last', and job config + view config save/update. I haven't spent enough time testing them so it's not the time yet to publish them.

cliffano commented 10 years ago

You can use the version on git by specifying the repo in your package.json dependencies.

catchharish commented 10 years ago

Hi Cliffano,

I do love nestor a lot and congrats on all your good work..

The confusion was because the readme points to your git file while npm pulls a different version of the file..

I completely understand that you have 2 different versions of the files for production and for git purposes.. no worries..

Just wanted to let you know so that you could remove the confusion if you deem fit.

Thanks Harish

Have you checked out http://taalmedia.com http://taalmedia.com ?

On Fri, Apr 4, 2014 at 6:15 PM, Cliffano Subagio notifications@github.comwrote:

You can use the version on git by specifying the repo in your package.json dependencies.

Reply to this email directly or view it on GitHubhttps://github.com/cliffano/nestor/issues/27#issuecomment-39625136 .

cliffano commented 10 years ago

@catchharish

Thanks Harish, it's actually a great feedback. My apology for the confusion.

I think the proper solution is to publish a site documentation which matches the published version, and then update the homepage value in package.json to point to that site. github.io is a suitable solution for this.

Please leave this issue open until I've put in that change.

Thanks again for the feedback, much appreciated.

catchharish commented 10 years ago

Hello Cliffano,

i would like your help in fixing an issue that i am having while using nestor.

Here is the code snippet, causing problem

    var opts = {};
    nestor.dashboard(opts, function (err, result) {
        if (!err) {

            var opts = {jobName: jenkinsJobName};

            var result = nestor._statusByName({jobName: opts.jobName} ,

result); console.log(result) response.send(result, 200); } else {

            console.log ('in monitor error');
            response.send(404, {errorMessage:err.toString()});;
        }

    });

Here is the error i keep getting

TypeError: Object # has no method 'filter' at Jenkins._statusByName (/Users/krish004/WebstormProjects/jarvis/node_modules/nestor/lib/jenkins.js:554:17)

your help would be much appreciated..

thanks harish

On Mon, Apr 7, 2014 at 12:08 AM, Cliffano Subagio notifications@github.comwrote:

@catchharish https://github.com/catchharish

Thanks Harish, it's actually a great feedback. My apology for the confusion.

I think the proper solution is to publish a site documentation which matches the published version, and then update the homepage value in package.json to point to that site. github.io is a suitable solution for this.

Please leave this issue open until I've put in that change.

Thanks again for the feedback, much appreciated.

— Reply to this email directly or view it on GitHubhttps://github.com/cliffano/nestor/issues/27#issuecomment-39701394 .

cliffano commented 10 years ago

I just tested your code with node 0.10 and 0.11 against http://ci.jenkins-ci.org and it worked fine.

One reason you might get that error is if data is not an array in _statusByName. Could you please debug what's the type and value of dashboard result?

Another thing you have to note is that _statusByName is not meant for public use. I'm not planning to remove it, but it won't be guaranteed for backward compatibility in future releases.

catchharish commented 10 years ago

thanks Cliffano..

i had to add a single value to an array to make it work.. no worries

one other 'issue' , I notice is when i invoke the nestor build command. I notice it does not return anything. So if i were to trigger the build job multiple times, nestor.build always returns a 'success', though the underlying jenkins does not seem to accept the jobs?

any idea what could be happening ? ᐧ

Have you checked out http://taalmedia.com http://taalmedia.com ?

On Sat, May 3, 2014 at 5:30 PM, Cliffano Subagio notifications@github.comwrote:

I just tested your code with node 0.10 and 0.11 against http://ci.jenkins-ci.org and it worked fine.

One reason you might get that error is if data is not an array in _statusByName. Could you please debug what's the type and value of dashboard result?

Another thing you have to note is that _statusByName is not meant for public use. I'm not planning to remove it, but it won't be guaranteed for backward compatibility in future releases.

— Reply to this email directly or view it on GitHubhttps://github.com/cliffano/nestor/issues/27#issuecomment-42120360 .

cliffano commented 9 years ago

That is because nestor relies on the response code that Jenkins returns. nestor will give 'success' as long Jenkins responds with 200 or 201 nestor will give 'failure' for 404, 405 nestor will give unexpected 'failure' for anything else

In your case, triggering the build job multiple times causes Jenkins to respond with a set of 200s, but the server itself might do something smart like knowing that the requests were sent within a short period of time. I'm just guessing here, you'll need to look at Jenkins code to figure out how it behaves, perhaps check out the Jenkins log for any clue.