IT/Linux
Jenkins Config.xml 수정 후 Reload [CLI사용]
Bigtrue
2021. 1. 14. 11:18
Jenkins Config.xml 수정 후 Reload [CLI사용]
Config.xml 값 수정시 Jenkins 서버에 바로 반영이 진행되지않음
Manager Jenkins -> Reload Configuration from disk 진행 필요
아래 호출로 바로 reload 가능
파일은 http://jenkins/cli/ 에서 down 가능
java -jar jenkins-cli.jar -s [JENKINS_URL] -auth [ID:PW] reload-configuration
XML 수정 Code
import xml.etree.ElementTree as ET
configPath = 'jenkins path'
jobName = 'job name'
configFile = configPath + jobName + '/config.xml'
configXml = open(configFile, 'rt', encoding='UTF8')
tree = ET.parse(configXml)
root = tree.getroot()
for ch in root.iter('spec'):
print(ch.text)
ch.text = '변경 내용'
tree.write(configFile)