30
30
WORKSPACE = 'WORKSPACE'
33
def get_package_globs(series, arch):
34
series_number = SERIES_TO_NUMBERS[series]
33
def package_regexes(series, arch):
34
series_number = SERIES_TO_NUMBERS[series].replace('.', r'\.')
35
regex_core = re.compile(
36
r'^juju-core_.*%s.*%s\.deb$' % (series_number, arch))
37
regex_local = re.compile(
38
r'^juju-local_.*%s.*all\.deb$' % series_number)
36
'core': 'juju-core_*%s*_%s.deb' % (series_number, arch),
37
'local': 'juju-local_*%s*_all.deb' % series_number,
41
def get_debian_packages(credentials, workspace, series, arch, revision_build):
45
def get_debian_packages(jenkins, workspace, series, arch, revision_build):
46
builds = builds_for_revision(PUBLISH_REVISION_JOB, revision_build, jenkins)
48
logging.error('No builds found for revision_build %s' % revision_build)
51
build_info = builds[0]
43
package_globs = get_package_globs(series, arch)
53
regexes = package_regexes(series, arch)
45
for package, glob in package_globs.items():
46
artifacts = get_artifacts(
47
credentials, PUBLISH_REVISION, revision_build, glob,
48
workspace, dry_run=False, verbose=False)
49
file_path = os.path.join(workspace, artifacts[0].file_name)
50
result[package] = file_path
55
for artifact in build_info['artifacts']:
56
filename = artifact['fileName']
57
for package, matcher in regexes.items():
58
if matcher.search(filename) is not None:
59
package_url = '%s/artifact/%s' % (
60
build_info['url'], filename)
61
local_path = os.path.join(workspace, filename)
63
'copying %s from build %s' % (
64
filename, build_info['number']))
65
result[package] = local_path
66
command = 'wget -q -O %s %s' % (
67
local_path, package_url)
68
subprocess.check_call(command.split(' '))
52
71
for file_path in result.values():
53
72
if os.path.exists(file_path):
132
151
'this option is a revision_build number. The debian packages '
133
152
'are retrieved from a run of the publish-revision for this '
134
153
'revision_build.'))
135
add_credential_args(parser)
136
154
args = parser.parse_args()
137
155
clean_workspace(args.workspace)
156
jenkins = Jenkins(JENKINS_URL)
138
157
if args.use_ci_juju_packages is not None:
139
credentials = get_credentials(args)
140
158
package_info = get_debian_packages(
141
credentials, args.workspace, args.series, args.arch,
159
jenkins, args.workspace, args.series, args.arch,
142
160
args.use_ci_juju_packages)
143
161
if 'core' not in package_info:
144
162
logging.error('Could not find juju-core package')