Open NicoR45 opened 3 days ago
@NicoR45 you should pass the dict instead of string.
from api4jenkins import Jenkins
j = Jenkins(url_base, auth=(MyUser, MyPassword), timeout=10)
args = {'nodeDescription': '', 'numExecutors': 1, 'remoteFS': '/home/jenkins', 'labelString': '', 'mode': 'NORMAL', 'retentionStrategy': {'stapler-class': 'hudson.slaves.RetentionStrategy$Always'}, 'nodeProperties': {'stapler-class-bag': 'true'}, 'launcher': {'stapler-class': 'hudson.slaves.JNLPLauncher'}}
j.nodes.create(**args)
here you can find example: https://api4jenkins.readthedocs.io/en/latest/user/example.html#node
Hi, Indeed... although I thought I'd tried with the arguments in a dict. I don't know what I've done :confused:
For those interested in this small issue, I had to add the 'name' argument to the dict:
Traceback (most recent call last):
File "b:\MyPath\python\test.py", line 59, in <module>
j.nodes.create(**args)
TypeError: Nodes.create() missing 1 required positional argument: 'name'
After correction:
args = {'name': 'MyAgent test', 'nodeDescription': '', 'numExecutors': 1, 'remoteFS': '/home/jenkins', 'labelString': '', 'mode': 'NORMAL', 'retentionStrategy': {'stapler-class': 'hudson.slaves.RetentionStrategy$Always'}, 'nodeProperties': {'stapler-class-bag': 'true'}, 'launcher': {'stapler-class': 'hudson.slaves.JNLPLauncher'}}
j.nodes.create(**args)
Thank you joelee2012 :thumbsup:
Hi, I'm trying to create an agent.
My code is:
Returned traceback :
What have I done wrong? What character ':' does the error message refer to?