Fix python-gitlab not sorting jobs by id
This commit is contained in:
parent
bfff5648df
commit
6d35558299
2 changed files with 8 additions and 7 deletions
|
|
@ -17,16 +17,18 @@ class GitLab:
|
||||||
def getLastSuccessfulJob(self, ref, name):
|
def getLastSuccessfulJob(self, ref, name):
|
||||||
pipelines = self._project.pipelines.list()
|
pipelines = self._project.pipelines.list()
|
||||||
|
|
||||||
successful_master_jobs = []
|
last_successful_job = None
|
||||||
for pipeline in pipelines:
|
for pipeline in pipelines:
|
||||||
jobs = pipeline.jobs.list()
|
jobs = pipeline.jobs.list()
|
||||||
for job in jobs:
|
for job in jobs:
|
||||||
if job.ref == ref and job.attributes['name'] == name and job.attributes['status'] == 'success':
|
if job.ref == ref and job.attributes['name'] == name and job.attributes['status'] == 'success':
|
||||||
successful_master_jobs.append(job)
|
if last_successful_job is not None:
|
||||||
|
if job.attributes['id'] > last_successful_job.attributes['id']:
|
||||||
|
last_successful_job = job
|
||||||
|
else:
|
||||||
|
last_successful_job = job
|
||||||
|
|
||||||
job = successful_master_jobs[-1]
|
return last_successful_job
|
||||||
|
|
||||||
return job
|
|
||||||
|
|
||||||
def downloadArtifact(self, job, sourcePath, destPath):
|
def downloadArtifact(self, job, sourcePath, destPath):
|
||||||
job_id = job.attributes['id']
|
job_id = job.attributes['id']
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,8 @@ def checkDebianDistro(distro):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
gitlab = GitLab()
|
||||||
for distro in argv[1:]:
|
for distro in argv[1:]:
|
||||||
#for distro in ['stretch']:
|
|
||||||
gitlab = GitLab()
|
|
||||||
job = gitlab.getLastSuccessfulJob('master', 'squashfs_master')
|
job = gitlab.getLastSuccessfulJob('master', 'squashfs_master')
|
||||||
gitlab.downloadArtifact(job, 'images/debian-' + distro + '.dpkg-list', 'debian-' + distro + '.dpkg-list')
|
gitlab.downloadArtifact(job, 'images/debian-' + distro + '.dpkg-list', 'debian-' + distro + '.dpkg-list')
|
||||||
if checkDebianDistro(distro) > 0:
|
if checkDebianDistro(distro) > 0:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue