GoCD извлекает предыдущий артефакт из пайплайна

У меня есть конвейер GoCD, который создает артефакт. Есть ли способ вытащить артефакт предыдущего запуска для сравнения с текущим запуском?


person Todoy    schedule 02.05.2017    source источник


Ответы (1)


Вы можете сделать это с помощью библиотеки yagocd:

#!/usr/bin/env python

import logging

from yagocd import Yagocd

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger("requests").setLevel(logging.WARNING)

    go = Yagocd(
        server='https://build.gocd.io',
        # auth=('username', 'password'),
    )

    # login as guest
    go._session.get('https://build.gocd.io/go/plugin/interact/gocd.guest.user.auth.plugin/index')

    pipeline = go.pipelines['plugins']
    last_instance, previous_to_last = pipeline.history()[:2]

    last_artifacts = list()
    previous_to_last_artifacts = list()

    for stage in last_instance:
        for job in stage:
            for root, folder, files in job.artifacts:
                for artifact in files:
                    last_artifacts.append(artifact)

    for stage in previous_to_last:
        for job in stage:
            for root, folder, files in job.artifacts:
                for artifact in files:
                    previous_to_last_artifacts.append(artifact)

    # Now you can compare artifacts
    # how you like: either calculate set diff
    # or review content difference via `artifact.fetch()` method.
person grundic    schedule 08.05.2017