Comments (8)
Hi Aleksey,
Did you create a jenkins user to run the jobs? If you have a user with
permission to run the job and initialize the jankinsapi like below, it should work.
api = jenkins.Jenkins(baseurl=, username=, password=)
from jenkinsflow.
No, it doesn't work.
From some version of Jenkins job can be only triggered by POST request. Urllib2, used by jenkinsapi, will only generate POST request if there are non empty parameters has been passed to function used to access URL.
Here what happens:
- jenkinsflow passes None as securitytoken parameter to jenkinsapi.job.invoke
- jenkinsapi.job.invoke passes token=None to jenkinsapi.job.get_build_triggerurl, so it will return tuple: url with "$JOB_NAME/build" and params=None
- jenkinsapi.job.invoke will call jenkinsapi.job.hit_url with no parameters
- jenkinsapi.job.hit_url will pass empty parameters to urllib
- urllib will issue GET request to Jenkins
- Jenkins will reply with
<!DOCTYPE html><html><head>
<title>Form post required [Jenkins]</title><link rel="stylesheet...
If I try to pass "token" as a parameter to a job, on step 2 above result will be a tuple: url with "$JOB_NAME/buildWithParams" and params="token=token_value".
This is wrong because job doesn't have parameters and Jenkins will reply with error 500: Job doesn't have parameters
Hope this helps!
from jenkinsflow.
Which versions of Jenkins/Jenkinsapi are you at now?
from jenkinsflow.
Hi Aleksey,
It is the version of jenkinsapi available via pip that is outdated. Sorry for not realizing this earlier.
Instead install the latest jenkinsapi from git, then it works.
git clone https://github.com/salimfadhley/jenkinsapi.git
sudo python ./setup.py install
I tested with latest git jenkinsapi 97051dff04f50f39502b7c5c18f22940dda72264
and Jenkins ver. 1.514 available today.
from jenkinsflow.
Still doesn't work for me.
Jenkins ver. 1.509.1, jenkinsapi installed from github
Perhaps this has been fixed in later Jenkins? Will try it now.
Started by user anonymous
[EnvInject] - Loading node environment variables.
Building in workspace /devshared/home/maleksey/jenkins-test/workspace/TEST-jenkinsflow
[TEST-jenkinsflow] $ /devshared/home/maleksey/virtualenv-1.9.1/jenkins/bin/python /tmp/shiningpanda4074820405597151072.py
== Legend ==
Serial builds: []
Parallel builds: ()
Invoking (w/x,y/z): w=current invocation in current flow scope, x=max in scope, y=total number of invocations, z=total max invocations
Elapsed time: 'after: x/y': x=time spent during current run of job, y=time elapsed since start of outermost flow
Queuing jobs for serial run: [
Queuing job: ADMIN-flow-1 'ADMIN-flow-1' Status IDLE - latest build: ADMIN-flow-1 #5
Queuing jobs for parallel run: (
Queuing job: ADMIN-flow-2 'ADMIN-flow-2' Status IDLE - latest build: None
Queuing job: ADMIN-flow-3 'ADMIN-flow-3' Status IDLE - latest build: None
)
Queuing job: ADMIN-flow-1 'ADMIN-flow-1' Status IDLE - latest build: ADMIN-flow-1 #5
]
Invoking (1/1,1/1): ['ADMIN-flow-1', ('ADMIN-flow-2', 'ADMIN-flow-3'), 'ADMIN-flow-1']
Invoking (1/1,1/1): http://sabrebuild1.uk.standardchartered.com:8180/job/ADMIN-flow-1 - /build
Traceback (most recent call last):
File "/tmp/shiningpanda4074820405597151072.py", line 42, in <module>
main()
File "/tmp/shiningpanda4074820405597151072.py", line 38, in main
ctrl1.invoke('flow-1')
File "/devshared/home/maleksey/src/jenkinsflow/jobcontrol.py", line 413, in __exit__
self.wait_for_jobs()
File "/devshared/home/maleksey/src/jenkinsflow/jobcontrol.py", line 383, in wait_for_jobs
last_report_time = self._check(start_time, last_report_time)
File "/devshared/home/maleksey/src/jenkinsflow/jobcontrol.py", line 331, in _check
last_report_time = job._check(start_time, last_report_time)
File "/devshared/home/maleksey/src/jenkinsflow/jobcontrol.py", line 142, in _check
self.job.invoke(invoke_pre_check_delay=0, block=False, params=self.params if self.params else None)
File "build/bdist.linux-x86_64/egg/jenkinsapi/job.py", line 125, in invoke
AssertionError: The job did not schedule.
Build step 'Custom Python Builder' marked build as failure
Notifying upstream projects of job completion
Finished: FAILURE
from jenkinsflow.
This problem only happens if Jenkins security is switched on.
If Jenkins is secured, then /build URL will be required to be triggered by POST with security token. If Jenkins in not secured - then /build is triggered by GET.
But problem with jenkinsflow still remains. There shall be an option to specify security token for build.
from jenkinsflow.
Hi Aleksey,
Today is a holiday here, but I will implement a token option tonight when I
get home from my family visit.
from jenkinsflow.
Hi Aleksey,
I've added a 'securitytoken' argument to the the serial/parallel flow constructors. It can be specified at the top level flow and possibly overridded in child flows. The flow will put the token on the job invocations.
from jenkinsflow.
Related Issues (19)
- More information about installation is needed HOT 2
- Demo scripts require proxytools to be installed HOT 2
- Make it easier to see job status on failure HOT 4
- Dump flow HOT 4
- Put jenkinsflow to pypi HOT 12
- Put sphinx generated documentation to ReadTheDocs HOT 2
- Minor issue with Jenkins.__init__ in specialized_api HOT 1
- How to schedule pipeline even if some jobs are running? HOT 2
- Is it possible to add timing information to final report? HOT 3
- Flow callback function HOT 1
- Method to get flow results
- Jenkinsflow doesn't work if Jenkins is not served from "/" HOT 1
- subprocess dependency HOT 1
- Pipeline jobs executed in parallel end up running the same build HOT 7
- Jenkinsflow returns SUCCESS when flow has failed HOT 5
- Timeout HOT 3
- Adding _DelayedSingleJob HOT 3
- Shebang in .py files HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jenkinsflow.