Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
recursively get all downstream jenkins artifact urls
#!/usr/bin/env python
Run on Jenkins to print a url for each artifact generated by a downstream multijob build.
import os
import requests
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
Copy link

  • note that the subBuilds key might be specific to the multijob plugin; I haven't tested this without it.
  • we use this at Venmo to implement a fork/join style workflow -- the top-most build creates many parallel children, waits for them to finish, then collects their results (tests, coverage, etc) and merges them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment