Comments (5)
Sorry wasted your time....got it facepalm
I'll post my now running code as example, if someone needs it
jenkins_server = api4jenkins.Jenkins('https://myjenkins.example.com:8443', auth=('someuser','the_api_token'),verify=False)
user = jenkins_server.me.exists()
version = jenkins_server.version
print(str(user))
print(str(version))
job = jenkins_server.get_job("API-TEST - JOB")
print(job)
lauf = job.build(TEXT1="C",TEXT2="lalala")
print(lauf)
Output:
True
2.277.4
<FreeStyleProject: https://myjenkins.example.com:8443/job/API-TEST%20-%20JOB/>
<QueueItem: https://myjenkins.example.com:8443/queue/item/1149/>
and the jenkis job runs correctly with the Parameters: "C" (of the dropdown-box) and "lalala" (of the text-in-field)
from api4jenkins.
don't know how do you call the method, but the doc may help https://api4jenkins.readthedocs.io/en/latest/user/example.html#project
from api4jenkins.
I have an example Jenkins-Job which has this Parameter-Definition
.....
"parameterDefinitions" : [
{
"_class" : "hudson.model.ChoiceParameterDefinition",
"defaultParameterValue" : {
"_class" : "hudson.model.StringParameterValue",
"value" : "A"
},
"description" : "Auswahlfeld",
"name" : "TEXT1",
"type" : "ChoiceParameterDefinition",
"choices" : [
"A",
"B",
"C"
]
},
{
"_class" : "hudson.model.TextParameterDefinition",
"defaultParameterValue" : {
"_class" : "hudson.model.StringParameterValue",
"value" : "Das ist ein Test"
},
"description" : "Textfeld",
"name" : "TEXT2",
"type" : "TextParameterDefinition"
}
]
.....
"description" : "API TEST - MG",
"displayName" : "API-TEST - MG",
"displayNameOrNull" : null,
"fullDisplayName" : "API-TEST - MG",
"fullName" : "API-TEST - MG",
"name" : "API-TEST - MG",
.....
"Auswahlfeld == Drop-down/Choice-Field"
"Textfeld == String-Input-Field"
I as your doc statet... I do the following
jenkins_server = api4jenkins.Jenkins('https://lvasp-jenkins.example.com', auth=('myuser','99999tokenid9999'),
verify=False)
job = jenkins_server.get_job("API-TEST - MG")
using
item = job.build_job() produces a
builtins.AttributeError: 'FreeStyleProject' object has no attribute 'build_job'
exception
Using a
payload = "TEXT1=C&TEXT2=LLILI"
header = {'Content-Type': "application/x-www-form-urlencoded"}
lauf = jenkins_server.build_job("API-TEST - MG",headers=header,data=payload)
AFTER changing
....\site-packages\api4jenkins\job.py
Line 137
from: resp = self.handle_req('POST', entry, params=params)
to: resp = self.handle_req('POST', entry, **params)
works like a charm
Propably I get something wrong, but in my opinion the fixed hande_req-parameter 'params' didnt work.
and your documentation of .... arg1='string', arg2='string' is sorry... a litte bit irritating.
How about a real example
Do a freestyle-Job like my one, implement a build-With-Parameters and try it.
(Changed: removed the hasmarks of the posted changed lines)
from api4jenkins.
try this :
item = job.build(TEXT1='C', TEXT2='LLILI')
from api4jenkins.
yes, i agree with you the doc should be improved, but unfortunately i don't have time recently. i'm happy if you or someone can help on this.
from api4jenkins.
Related Issues (20)
- getting jsondecode error HOT 5
- add return type to methods like get_job HOT 1
- get all the configuration properties from a job ? HOT 1
- Build number included string occured error. HOT 5
- Approving the Pending Input is not working when Jenkins runs on Subpath HOT 1
- In Jenkins(jenkins_url, auth=(user,token)), jenkins_url changes port to 80 HOT 2
- proxy agent setting HOT 7
- Build job with files. HOT 10
- v1.13 job.get_build(build_number) return None , v1.12 OK HOT 1
- Change node's labels by which api? HOT 2
- Is the library thread-safe? HOT 1
- Please document 100 job limit on get_build(number) HOT 1
- jenkins.get_job().build(with parameters) HOT 2
- Cannot get the specify build use get_build(number) HOT 3
- Unable to store secret file credentials correctly HOT 1
- [FEATURE REQUEST] Credentials domains HOT 2
- v2.0.0 syntax errors when using Python 3.7 due to walrus operator HOT 2
- Unable to control the logger from v.2.0.0 or newer HOT 3
- ResourceWarning: unclosed socket in pytest HOT 3
- WorkflowJob object has no attribute 'get_build' HOT 2
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 api4jenkins.