commitSha = os.getenv('GITHUB_HEAD_SHA') taskGroupId = os.getenv('TASK_ID') print('debug: auth.currentScopes') print(auth.currentScopes()) azurePurgeTaskId = slugid.nice() createTask( queue=queue, taskId=azurePurgeTaskId, taskName='00 :: purge deprecated azure resources', taskDescription= 'delete orphaned, deprecated, deallocated and unused azure resources', maxRunMinutes=60, retries=5, retriggerOnExitCodes=[123], provisioner='relops', workerType='win2019', priority='high', features={'taskclusterProxy': True}, commands=[ 'git clone https://github.com/mozilla-platform-ops/cloud-image-builder.git', 'cd cloud-image-builder', 'git reset --hard {}'.format(commitSha), 'powershell -File ci\\purge-deprecated-azure-resources.ps1' ], scopes=['secrets:get:project/relops/image-builder/dev'], taskGroupId=taskGroupId) for platform in ['amazon', 'azure']: for key in ['win10-64', 'win10-64-gpu', 'win7-32', 'win7-32-gpu']: configPath = '{}/../config/{}.yaml'.format(os.path.dirname(__file__), key) with open(configPath, 'r') as stream:
createTask( queue=taskcluster.Queue(taskcluster.optionsFromEnvironment()), image='python', taskId=slugid.nice(), taskName='00 :: create maintenance and image build tasks', taskDescription= 'determine which windows cloud images should be built, where they should be deployed and trigger appropriate build tasks for the same', provisioner='relops', workerType='decision', features={'taskclusterProxy': True}, env={'GITHUB_HEAD_SHA': os.getenv('TRAVIS_COMMIT')}, commands=[ '/bin/bash', '--login', '-c', 'git clone https://github.com/mozilla-platform-ops/cloud-image-builder.git && cd cloud-image-builder && git reset --hard {} && pip install azure-mgmt-compute boto3 pyyaml slugid taskcluster urllib3 | grep -v "^[[:space:]]*$" && python ci/create-image-build-tasks.py' .format(os.getenv('TRAVIS_COMMIT')) ], scopes=[ 'generic-worker:os-group:relops/win2019/Administrators', 'generic-worker:run-as-administrator:relops/*', 'queue:create-task:highest:relops/*', 'queue:create-task:very-high:relops/*', 'queue:create-task:high:relops/*', 'queue:create-task:medium:relops/*', 'queue:create-task:low:relops/*', 'queue:route:index.project.relops.cloud-image-builder.*', 'queue:scheduler-id:-', 'queue:scheduler-id:taskcluster-github', 'worker-manager:manage-worker-pool:gecko-1/win*', 'worker-manager:manage-worker-pool:gecko-3/win*', 'worker-manager:manage-worker-pool:gecko-t/win*', 'worker-manager:manage-worker-pool:mpd001-1/win*', 'worker-manager:manage-worker-pool:mpd001-3/win*', 'worker-manager:manage-worker-pool:relops/win*', 'worker-manager:provider:aws', 'worker-manager:provider:azure', 'secrets:get:project/relops/image-builder/dev' ])
platformClient = { 'azure': ComputeManagementClient( ServicePrincipalCredentials( client_id = secret['azure']['id'], secret = secret['azure']['key'], tenant = secret['azure']['account']), secret['azure']['subscription']) } if runEnvironment == 'travis': commitSha = os.getenv('TRAVIS_COMMIT') taskGroupId = slugid.nice() createTask( queue = queue, taskId = taskGroupId, taskName = '00 :: task group placeholder', taskDescription = 'this task only serves as a task grouping when triggered from travis. it does no actual work', provisioner = 'relops', workerType = 'win2019', commands = [ 'echo "task: {}, sha: {}"'.format(taskGroupId, commitSha) ]) elif runEnvironment == 'taskcluster': commitSha = os.getenv('GITHUB_HEAD_SHA') taskGroupId = os.getenv('TASK_ID') print('debug: auth.currentScopes') print(auth.currentScopes()) createTask( queue = queue, taskId = slugid.nice(), taskName = '00 :: purge deprecated azure resources', taskDescription = 'delete orphaned, deprecated, deallocated and unused azure resources', maxRunMinutes = 60, provisioner = 'relops',
print('[debug] auth.currentScopes:') for scope in auth.currentScopes()['scopes']: print(' - {}'.format(scope)) yamlLintTaskId = slugid.nice() createTask( queue = queue, image = 'python', taskId = yamlLintTaskId, taskName = '00 :: validate all yaml files in repo', taskDescription = 'run a linter against each yaml file in the repository', maxRunMinutes = 10, retries = 5, retriggerOnExitCodes = [ 123 ], provisioner = 'relops-3', workerType = 'decision', priority = 'high', commands = [ '/bin/bash', '--login', '-c', 'git clone https://github.com/mozilla-platform-ops/cloud-image-builder.git && cd cloud-image-builder && git reset --hard {} && pip install yamllint | grep -v "^[[:space:]]*$" && yamllint .'.format(commitSha) ], taskGroupId = taskGroupId ) azurePurgeTaskIds = { 'default': slugid.nice() } if purgeRelopsResources: azurePurgeTaskIds['relops'] = slugid.nice() azurePurgeTaskIds['rg-packer-through-cib'] = slugid.nice() if purgeTaskclusterResources: