PortMan
PortMan

Reputation: 4533

jenkinsapi python script works but throws error

I've got a simple python program that uses the Jenkins Rest API. All it's supposed to do is start the jenkins job "MyJob"

#! /usr/bin/env python
from jenkinsapi.jenkins import Jenkins

server = Jenkins('http://localhost:8080')
server.build_job("MyJob")

When I run this script, MyJob does build on the Jenkins server, but the script throws this error:

Traceback (most recent call last):
  File "./build.py", line 14, in <module>
    build_job1()
  File "./build.py", line 7, in build_job1
    server.build_job("MyBuild")
  File "build/bdist.cygwin-2.0.2-i686/egg/jenkinsapi/jenkins.py", line 165, in build_job
  File "build/bdist.cygwin-2.0.2-i686/egg/jenkinsapi/job.py", line 223, in invoke
ValueError: Not a Queue URL: http://localhost:8080/queue/item/37/

Am I doing something wrong?

Upvotes: 0

Views: 1389

Answers (2)

JasonRobinson
JasonRobinson

Reputation: 107

Is your script running on the same machine as the Jenkins host? If not, then Localhost will mean something completely different for your machine running the Python command vs the Jenkins machine.

Upvotes: 0

Stan
Stan

Reputation: 3461

Configure Jenkins URL at Manage Jenkins » Configure System » Jenkins Location » Jenkins URL, so it would be the same as the real address.

related issue (but I guess they will not fix it, it's not really a bug) - https://issues.jenkins-ci.org/browse/JENKINS-26150

Upvotes: 2

Related Questions