我有一个创建工件的GoCD管道。有没有办法让我把上一次运行的工件与当前运行进行比较?
答案 0 :(得分: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.