commit message from python script
This commit is contained in:
@@ -60,6 +60,7 @@ class steuer_rechner:
|
||||
print("richtig")
|
||||
elif my_input == 'y':
|
||||
print("richtg eingabe y")
|
||||
modify_data = steuer_rechner.modify_data(self, month="Okt", money=1231.12)
|
||||
elif my_input == 'n':
|
||||
print("raus")
|
||||
break
|
||||
|
||||
@@ -7,7 +7,7 @@ server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', passw
|
||||
user = server.get_whoami()
|
||||
version = server.get_version()
|
||||
#vars_für den Job
|
||||
job_name="test_4"
|
||||
job_name="test_5"
|
||||
finish_config=job_name + "_config.xml"
|
||||
git_url='https://gitea.schlaubistechtalk.de/JonnyBravo/test_play.git'
|
||||
command_line='./test_play.yml'
|
||||
|
||||
43
jenkins/test_5_config.xml
Normal file
43
jenkins/test_5_config.xml
Normal 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>https://gitea.schlaubistechtalk.de/JonnyBravo/test_play.git</url>
|
||||
<credentialsId>e4acf1ed-a858-429d-b5a6-c149431563db</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>./test_play.yml</command>
|
||||
<configuredLocalRules/>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#! /usr/bin/env python3.10
|
||||
|
||||
import os
|
||||
import jenkins, os
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
#connect
|
||||
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
|
||||
|
||||
|
||||
def show_all_files_directory(dir_path = str, search_endung = False, search_string = False):
|
||||
li_all = []
|
||||
@@ -23,10 +28,9 @@ def show_all_directory(dir_path = str, search_endung = False, search_string = Fa
|
||||
for root_folder, dirs, files in os.walk(dir_path, topdown=False):
|
||||
for name in dirs:
|
||||
FullPATH = str(os.path.join(root_folder, name))
|
||||
if name == search_string:
|
||||
#print(name)
|
||||
if not name.find(search_string) == -1:
|
||||
li_all.append(FullPATH)
|
||||
print(FullPATH)
|
||||
|
||||
return li_all
|
||||
|
||||
|
||||
@@ -39,12 +43,25 @@ def modify_jenkins_configfile(config_file_list = list):
|
||||
print(line.rstrip("\n"))
|
||||
print("#" * len(config_file_FullPath))
|
||||
|
||||
def added_config_to_jenkins_xml(config_xml = str):
|
||||
xml_root = ET.parse(config_xml).getroot()
|
||||
xml_str = ET.tostring(xml_root, encoding='utf8', method='xml').decode()
|
||||
|
||||
for strategy in xml_root.findall('sources/data/jenkins.branch.BranchSource'):
|
||||
value = strategy.get('id')
|
||||
print(strategy.get('id'))
|
||||
print(value)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
#test = show_all_files_directory(dir_path=os.sep + "home" + os.sep + "jonnybravo" + os.sep + ".jenkins" + os.sep + "data" + os.sep + "jobs", search_string="config.xml")
|
||||
test2 = show_all_directory(dir_path=os.sep + "home" + os.sep + "jonnybravo" + os.sep + ".jenkins" + os.sep + "data" + os.sep + "jobs", search_string="ansible_test")
|
||||
find_folder = show_all_directory(dir_path=os.sep + "home" + os.sep + "jonnybravo" + os.sep + ".jenkins" + os.sep + "data" + os.sep + "jobs", search_string="mulit")
|
||||
for config_file in find_folder:
|
||||
file = config_file + os.sep + "config.xml"
|
||||
print(file)
|
||||
added_config_to_jenkins_xml(file)
|
||||
#modify_jenkins_configfile(config_file_list=test)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
20
jenkins_modify_jobs/test.py
Normal file
20
jenkins_modify_jobs/test.py
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import jenkins
|
||||
|
||||
if __name__ == '__main__':
|
||||
#server = Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
|
||||
server = jenkins.Jenkins('https://man-dan-03:9443', username='JonnyBravo', password='113c3449636622439627ab1d51454fc07c')
|
||||
job_config = server.get_job_config('mulit_pipeline')
|
||||
#print(job_config)
|
||||
#config=job.get_config()
|
||||
old_config_part = """ <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
|
||||
<properties class="empty-list"/>
|
||||
</strategy>"""
|
||||
new_config_part = """ <strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
|
||||
<properties class="-----------------------------------"/>
|
||||
</strategy>"""
|
||||
new = job_config.replace(new_config_part, old_config_part)
|
||||
server.reconfig_job('mulit_pipeline', new)
|
||||
#new = config.replace('oldvalue', 'newvalue')
|
||||
#job.update_config(new)
|
||||
Reference in New Issue
Block a user