commit message from python script

This commit is contained in:
2023-04-25 20:00:01 +02:00
parent eab802a5b9
commit 446c080d2a
2 changed files with 70 additions and 0 deletions

43
jenkins/example_xml.xml Normal file
View File

@@ -0,0 +1,43 @@
<?xml version='1.1' encoding='UTF-8'?>
<project>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@5.0.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>{git_url}</url>
<credentialsId>4ee2c832-863c-41c3-8f9b-0962c7b8439f</credentialsId>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="empty-list"/>
<extensions/>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers>
<hudson.triggers.SCMTrigger>
<spec>H/2 * * * *</spec>
<ignorePostCommitHooks>false</ignorePostCommitHooks>
</hudson.triggers.SCMTrigger>
</triggers>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command>{command}</command>
<configuredLocalRules/>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

27
jenkins/read_version.py Normal file
View File

@@ -0,0 +1,27 @@
import jenkins, os
import xml.etree.ElementTree as ET
#connect
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='116a45abc20fff8ae5ac67cdac1d65c687')
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)