Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Authentication issue #2

Open
lupul-cel-bun opened this issue Mar 4, 2014 · 7 comments
Open

Authentication issue #2

lupul-cel-bun opened this issue Mar 4, 2014 · 7 comments

Comments

@lupul-cel-bun
Copy link

I try to start a build on a server.
Server has authentication ON.
Job has parameters and token.
Call fails with:

   jenkins.JenkinsError: job "UniJob" does not exist
TCP Stream shows:
   HTTP/1.1 403 Forbidden

Do I have to do something extra, is my usage wrong?

I am using this sequence:

from jenkins import Jenkins as Trigger
...
def triggerBuild(serverURL, userName, password, jobName):
    myJob = Trigger(serverURL, userName, password)

    result = myJob.job('UniJob').build({"API":"rest","SUITE_TYPE":"bvt","FEATURES":"mine"},'0723')
    return result

Where:

    serverURL = "http://10.11.0.156:8080"
    userName = "yyyyyyyy" #<-------- insert your username here for Jenkins
    password="xxxxxxxxx"    #<---- insert your password here for jenkins 
    jobName = 'UniJob'

Using these versions:
root@oc6027363375:~ #python --version
Python 2.6.6
root@oc6027363375:~ #pip show jenkins-webapi

Name: jenkins-webapi
Version: 0.1.2
Location: /usr/lib/python2.6/site-packages
Requires: requests
root@oc6027363375:~ #pip show requests

Name: requests
Version: 2.2.1
Location: /usr/lib/python2.6/site-packages
Requires:

Target is:

 rpm -qa|grep  jenkins
jenkins-1.523-1.1.noarch
 uname -a
Linux xxxxxxxxxxx 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

We get this output:

Traceback (most recent call last):
  File "./jenkins_api_stuff.py", line 98, in <module>
    main()
  File "./jenkins_api_stuff.py", line 89, in main
    triggerBuild(serverURL, userName, password, jobName, waitForItToFinish=True)
  File "./jenkins_api_stuff.py", line 34, in triggerBuild
    result = myJob.job('UniJob').build({"API":"rest","SUITE_TYPE":"bvt","FEATURES":"mine"},'0723')
  File "/usr/lib/python2.6/site-packages/jenkins.py", line 65, in build
    self._not_exist_raise()
  File "/usr/lib/python2.6/site-packages/jenkins.py", line 31, in _not_exist_raise
    raise JenkinsError('job "%s" does not exist' % self.name)
jenkins.JenkinsError: job "UniJob" does not exist

TCP Stream is:

GET /job/UniJob/api/json?depth=0 HTTP/1.1
Host: 10.11.0.156:8080
Accept-Encoding: gzip, deflate, compress
Accept: */*
User-Agent: python-requests/2.2.1 CPython/2.6.6 Linux/2.6.32-358.11.1.el6.x86_64

HTTP/1.1 403 Forbidden
Server: Winstone Servlet Engine v0.9.10
Content-Type: text/html;charset=UTF-8
X-You-Are-Authenticated-As: anonymous
X-You-Are-In-Group: 
X-Required-Permission: hudson.model.Hudson.Read
X-Permission-Implied-By: hudson.security.Permission.GenericRead
X-Permission-Implied-By: hudson.model.Hudson.Administer
Content-Length: 867
Connection: Keep-Alive
Date: Tue, 04 Mar 2014 18:24:29 GMT
X-Powered-By: Servlet/2.5 (Winstone/0.9.10)
Set-Cookie: JSESSIONID.68d980e2=e1bf065f1bfe6157345450402c26ec02; Path=/; HttpOnly

<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fjob%2FUniJob%2Fapi%2Fjson%3Fdepth%3D0'/><script>window.location.replace('/login?from=%2Fjob%2FUniJob%2Fapi%2Fjson%3Fdepth%3D0');</script></head><body style='background-color:white; color:white;'>


Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Read
 ... which is implied by: hudson.security.Permission.GenericRead
 ... which is implied by: hudson.model.Hudson.Administer
-->

</body></html>                                                                    

The user has all the rigths on the Jenkins server.
Job is present and can be querried without issues using jenkinsapi 0.2.18

My machine is:

Linux oc6027363375.XXXXX.com 2.6.32-358.11.1.el6.x86_64 #1 SMP Wed May 15 10:48:38 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

Also
Using the instructions from http://jenkins-webapi.readthedocs.org/en/latest/
With the proper authentication data,

>>> j.job('UniJob').exists()
>>> j.job_exists('UniJob')

will always return False

@gvalkov
Copy link
Owner

gvalkov commented Mar 9, 2014

Hello and thank you for reporting this.

Can you check if the problem persists with jenkins-webapi == 0.2.0. A requests.HTTPError should be raised if there is an authentication error.

@lupul-cel-bun
Copy link
Author

Hi

I have read about it.
It seems to be something with the preemtive authentication.

I will try on the 11th as i am kind of away...

Regards,
Andrei

Sent from Yahoo Mail on Android

@gvalkov
Copy link
Owner

gvalkov commented Apr 8, 2014

Hello. I was wondering if you got to the bottom of this?

@lupul-cel-bun
Copy link
Author

Hi,

If i remember right, i think that i used another module. I will look it up and return with an answer on the 22nd.

Sorry for the delayed response,
Andrei

Sent from Yahoo Mail on Android

@dmetzman
Copy link

Hi, I am having the same issue as you were, could you let me know what you ended up doing?

@dchopson
Copy link

I get the same message shown in the "TCP Stream" in the original question. However, the circumstances are completely different. This is during authentication when trying to access Jenkins in the browser. We have Github auth enabled, and after Github auth hands back to Jenkins, I get a 403 forbidden with this message in the response. The admin has given me basically every permission available. And it fails on multiple browsers, multiple operating systems. Any ideas?

@dchopson
Copy link

dchopson commented Sep 3, 2014

I resolved this issue - the connection was being blocked by an app running on my Mac.

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

No branches or pull requests

4 participants