microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
.github/scripts/refresh_mirror/refresh-mirror.py
36lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # Licensed under the MIT License. |
| 3 | |
| 4 | import click |
| 5 | import time |
| 6 | import sys |
| 7 | from azure.devops.connection import Connection |
| 8 | from msrest.authentication import BasicAuthentication |
| 9 | |
| 10 | @click.command() |
| 11 | @click.argument('pipeline_id', required=True) |
| 12 | @click.argument('token', required=True) |
| 13 | @click.option('--organization', default='https://microsoft.visualstudio.com') |
| 14 | @click.option('--project', default='HyperVCloud') |
| 15 | @click.option('--debug', default=False, is_flag=True) |
| 16 | def main(pipeline_id: str, token: str, organization: str, project: str, debug: bool): |
| 17 | try: |
| 18 | client = Connection(base_url=organization, creds=BasicAuthentication('', token)).clients.get_build_client() |
| 19 | |
| 20 | build = { |
| 21 | 'definition': {'id': pipeline_id}, |
| 22 | 'templateParameters': {'branchToMirror': 'main', 'branchToUpdateSubmodule': 'main', 'updateSubmodule': 'true'}, |
| 23 | } |
| 24 | build = client.queue_build(build, project=project) |
| 25 | print(f'Scheduled build: {build.id}. Url: {organization}/{project}/_build/results?buildId={build.id}&view=results', file=sys.stderr) |
| 26 | |
| 27 | except: |
| 28 | if debug: |
| 29 | import pdb |
| 30 | import traceback |
| 31 | traceback.print_exc() |
| 32 | pdb.post_mortem() |
| 33 | raise |
| 34 | |
| 35 | if __name__ == '__main__': |
| 36 | main() |
| 37 | |