pollurl: Utilize convert_mapping_to_xml
Change-Id: I2d14f0c714e42c268d6fc411355a61347f89934f Signed-off-by: Tan Heng Yeow <E0032242@u.nus.edu>
This commit is contained in:
parent
de4fb862f3
commit
0586d9b3d3
@ -786,28 +786,28 @@ def pollurl(registry, xml_parent, data):
|
|||||||
urls = data.get('urls', [])
|
urls = data.get('urls', [])
|
||||||
if not urls:
|
if not urls:
|
||||||
raise JenkinsJobsException('At least one url must be provided')
|
raise JenkinsJobsException('At least one url must be provided')
|
||||||
|
mapping = [
|
||||||
|
('proxy', 'proxyActivated', False),
|
||||||
|
('timeout', 'timeout', 300),
|
||||||
|
('check-etag', 'checkETag', False),
|
||||||
|
('check-date', 'checkLastModificationDate', False)
|
||||||
|
]
|
||||||
for url in urls:
|
for url in urls:
|
||||||
entry = XML.SubElement(entries, namespace + 'URLTriggerEntry')
|
entry = XML.SubElement(entries, namespace + 'URLTriggerEntry')
|
||||||
XML.SubElement(entry, 'url').text = url['url']
|
XML.SubElement(entry, 'url').text = url['url']
|
||||||
XML.SubElement(entry, 'proxyActivated').text = \
|
|
||||||
str(url.get('proxy', False)).lower()
|
|
||||||
if 'username' in url:
|
if 'username' in url:
|
||||||
XML.SubElement(entry, 'username').text = url['username']
|
XML.SubElement(entry, 'username').text = url['username']
|
||||||
if 'password' in url:
|
if 'password' in url:
|
||||||
XML.SubElement(entry, 'password').text = url['password']
|
XML.SubElement(entry, 'password').text = url['password']
|
||||||
if 'check-status' in url:
|
if 'check-status' in url:
|
||||||
XML.SubElement(entry, 'checkStatus').text = 'true'
|
XML.SubElement(entry, 'checkStatus').text = 'true'
|
||||||
XML.SubElement(entry, 'statusCode').text = \
|
mapping.append(('check-status', 'statusCode', ''))
|
||||||
str(url.get('check-status'))
|
|
||||||
else:
|
else:
|
||||||
XML.SubElement(entry, 'checkStatus').text = 'false'
|
XML.SubElement(entry, 'checkStatus').text = 'false'
|
||||||
XML.SubElement(entry, 'statusCode').text = '200'
|
XML.SubElement(entry, 'statusCode').text = '200'
|
||||||
XML.SubElement(entry, 'timeout').text = \
|
|
||||||
str(url.get('timeout', 300))
|
helpers.convert_mapping_to_xml(
|
||||||
XML.SubElement(entry, 'checkETag').text = \
|
entry, url, mapping, fail_required=False)
|
||||||
str(url.get('check-etag', False)).lower()
|
|
||||||
XML.SubElement(entry, 'checkLastModificationDate').text = \
|
|
||||||
str(url.get('check-date', False)).lower()
|
|
||||||
check_content = url.get('check-content', [])
|
check_content = url.get('check-content', [])
|
||||||
XML.SubElement(entry, 'inspectingContent').text = \
|
XML.SubElement(entry, 'inspectingContent').text = \
|
||||||
str(bool(check_content)).lower()
|
str(bool(check_content)).lower()
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
<entries>
|
<entries>
|
||||||
<org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
|
<org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
|
||||||
<url>http://example.com/url1</url>
|
<url>http://example.com/url1</url>
|
||||||
<proxyActivated>false</proxyActivated>
|
|
||||||
<username>username</username>
|
<username>username</username>
|
||||||
<password>sekr3t</password>
|
<password>sekr3t</password>
|
||||||
<checkStatus>true</checkStatus>
|
<checkStatus>true</checkStatus>
|
||||||
<statusCode>202</statusCode>
|
<proxyActivated>false</proxyActivated>
|
||||||
<timeout>442</timeout>
|
<timeout>442</timeout>
|
||||||
<checkETag>false</checkETag>
|
<checkETag>false</checkETag>
|
||||||
<checkLastModificationDate>true</checkLastModificationDate>
|
<checkLastModificationDate>true</checkLastModificationDate>
|
||||||
|
<statusCode>202</statusCode>
|
||||||
<inspectingContent>true</inspectingContent>
|
<inspectingContent>true</inspectingContent>
|
||||||
<contentTypes>
|
<contentTypes>
|
||||||
<org.jenkinsci.plugins.urltrigger.content.SimpleContentType/>
|
<org.jenkinsci.plugins.urltrigger.content.SimpleContentType/>
|
||||||
@ -33,12 +33,13 @@
|
|||||||
</org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
|
</org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
|
||||||
<org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
|
<org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
|
||||||
<url>http://example.com/url2</url>
|
<url>http://example.com/url2</url>
|
||||||
<proxyActivated>true</proxyActivated>
|
|
||||||
<checkStatus>false</checkStatus>
|
<checkStatus>false</checkStatus>
|
||||||
<statusCode>200</statusCode>
|
<statusCode>200</statusCode>
|
||||||
|
<proxyActivated>true</proxyActivated>
|
||||||
<timeout>300</timeout>
|
<timeout>300</timeout>
|
||||||
<checkETag>true</checkETag>
|
<checkETag>true</checkETag>
|
||||||
<checkLastModificationDate>false</checkLastModificationDate>
|
<checkLastModificationDate>false</checkLastModificationDate>
|
||||||
|
<statusCode/>
|
||||||
<inspectingContent>true</inspectingContent>
|
<inspectingContent>true</inspectingContent>
|
||||||
<contentTypes>
|
<contentTypes>
|
||||||
<org.jenkinsci.plugins.urltrigger.content.XMLContentType>
|
<org.jenkinsci.plugins.urltrigger.content.XMLContentType>
|
||||||
|
Loading…
Reference in New Issue
Block a user