Open mmihir82 opened 4 years ago
Any exception produced?
it create a job with empty field
{"_class":"hudson.model.FreeStyleBuild","actions":[{"_class":"hudson.model.ParametersAction","parameters":[{"_class":"hudson.model.StringParameterValue","name":"registration_action","value":"IPAM and DNS"},{"_class":"hudson.model.StringParameterValue","name":"entries","value":""}]}
Here is code I ran:
class JENKINSLOGIN(object):
def __init__(self, url, username, pswd, useCrumb=True, ssl_verify=False):
self.jenkinsurl = url
self.username = username
self.password = pswd
self.useCrumb = useCrumb
self.ssl_verify = ssl_verify
def jenkins_login(self):
server = Jenkins(self.jenkinsurl, username=self.username, password=self.password, useCrumb=self.useCrumb, ssl_verify=self.ssl_verify)
return server
url = "https://localhost:8080"
j = JENKINSLOGIN(url, user, pswd)
job = j.jenkins_login().create_job(jenkins_job, params)
Output:
jenkinsapi.custom_exceptions.JenkinsAPIException: Operation failed. url=https://localhost:8080/createItem?name=coreinfra%2Fjob%2Fprod%2Fjob%2FDNStool%2Fjob%2FDDNS_Tool_v1, data={'parameter': [{'name': 'registration_action', 'value': 'DDNS_only'}, {'name': 'Note:', 'value': 'test02'}, {'name': 'entries', 'value': 'add, hostname02.localhost, 192.168.1.2/24\nadd, hostname01.localhost, 192.168.1.1/24\n'}]}, headers={'Content-Type': 'text/xml', 'Jenkins-Crumb': '8bfd1f3f77af7abcff904d4027def582'}, status=400, text=b'\n
I too face issue similar to this.
import jenkinsapi
from jenkinsapi.jenkins import Jenkins import os.path
data_file = open('test-data.txt', 'r') build_params = {"IMAGE":"test-image","test_URL":"www.test.com/test","AREA_NAME":"test","PARA":"4","TYPE":"custom"}
jenkins_url = "https://jenkins-pc.test.cci.test.com" username = "test_user" password = "passcode"
server = Jenkins(jenkins_url, username=username, password=password, timeout = 1200, lazy = True) job = "tenant/sec/value-Check" new_job = server[job] running_job_object = new_job.invoke(block=True, build_params=build_params, files={'tests.custom': data_file}) data_file.close()
Traceback (most recent call last):
File "executeJob.py_t", line 23, in
you may want to try https://api4jenkins.readthedocs.io/en/latest/index.html
ISSUE TYPE
Jenkinsapi VERSION: 0.3.11
Jenkins VERSION: 2.204.2
SUMMARY
I did curl, it creates the job but unable to pass the variables. Here is the curl command:
Fail to do post, not sure where is the issue. Thank you for your help in advance.