27 lines
850 B
Python
27 lines
850 B
Python
import jenkins, os
|
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
#connect
|
|
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
|
|
user = server.get_whoami()
|
|
version = server.get_version()
|
|
#vars_für den Job
|
|
job_name="test_4"
|
|
finish_config=job_name + "_config.xml"
|
|
git_url='https://gitea.schlaubistechtalk.de/JonnyBravo/test_play.git'
|
|
command_line='./test_play.yml'
|
|
|
|
print('Hello %s from Jenkins %s' % (user['fullName'], version))
|
|
|
|
with open("example_xml.xml", "rt") as fin:
|
|
with open(finish_config, "wt") as fout:
|
|
for line in fin:
|
|
fout.write(line.format(git_url=git_url,command=command_line ))
|
|
|
|
|
|
tree = ET.parse(finish_config)
|
|
root = tree.getroot()
|
|
xml_str = ET.tostring(root, encoding='utf8', method='xml').decode()
|
|
|
|
server.create_job(name=job_name,config_xml=xml_str) |