recursively get all downstream jenkins artifact urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Run on Jenkins to print a url for each artifact generated by a downstream multijob build. | |
""" | |
import os | |
import requests | |
JENKINS_URL = os.environ['JENKINS_URL'] | |
BUILD_URL = os.environ['BUILD_URL'] | |
def find_artifact_urls(build_url): | |
artifact_urls = [] | |
res = requests.get('%s/api/json' % build_url, verify=False).json() | |
if 'subBuilds' in res: | |
for subbuild in res['subBuilds']: | |
artifact_urls.extend(find_artifact_urls(JENKINS_URL + subbuild['url'])) | |
if 'artifacts' in res: | |
for artifact in res['artifacts']: | |
artifact_urls.append("%sartifact/%s" % (res['url'], artifact['relativePath'])) | |
return artifact_urls | |
for url in find_artifact_urls(BUILD_URL): | |
print url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
subBuilds
key might be specific to the multijob plugin; I haven't tested this without it.