forked from microsoft/dotnet-framework-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-imagebuilder.yml
More file actions
81 lines (73 loc) · 2.88 KB
/
run-imagebuilder.yml
File metadata and controls
81 lines (73 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
parameters:
- name: name
type: string
default: ""
- name: displayName
type: string
default: "Run ImageBuilder"
- name: serviceConnections
type: object
default: []
# - name: The name of the service connection argument that will be passed to the ImageBuilder command.
# For example, if the argument is --acr-service-connection, the name would be "acr".
# id: The service connection's ID (GUID).
# clientId: The client ID of the Managed Idendity backing the service connection (GUID).
# tenantId: The ID of the tenant that the Managed Identity is in (GUID).
- name: internalProjectName
type: string
default: null
- name: args
type: string
default: null
- name: condition
type: string
default: succeeded()
- name: continueOnError
type: boolean
default: false
- name: dockerClientOS
type: string
default: "linux"
# Additional docker run args inserted before the image name (Linux only).
# These are flags passed to `docker run` for the containerized ImageBuilder
# and must not be set for Windows jobs where ImageBuilder runs as a native
# executable. Used for signing (volume mounts, env files) or other
# job-specific docker configuration.
- name: linuxOnlyExtraDockerRunArgs
type: string
default: ""
steps:
- ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }}:
- task: PowerShell@2
${{ if ne(parameters.name, '') }}:
name: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
continueOnError: ${{ parameters.continueOnError }}
condition: ${{ parameters.condition }}
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
SYSTEM_OIDCREQUESTURI: $(System.OidcRequestUri)
inputs:
targetType: 'inline'
script: |
$serviceConnections = '${{ convertToJson(parameters.serviceConnections) }}'
Write-Host "Service connections:"
Write-Host "${serviceConnections}"
$serviceConnectionsJson = $serviceConnections | ConvertFrom-Json
$serviceConnectionsArgs = @()
foreach ($connection in $serviceConnectionsJson) {
$serviceConnectionsArgs += "--$($connection.name)-service-connection"
$serviceConnectionsArgs += "$($connection.tenantId):$($connection.clientId):$($connection.id)"
}
$(runAuthedImageBuilderBaseCmd) ${{ parameters.linuxOnlyExtraDockerRunArgs }} $(imageBuilderImageName) ${{ parameters.args }} @serviceConnectionsArgs
- ${{ else }}:
- task: PowerShell@2
${{ if ne(parameters.name, '') }}:
name: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
continueOnError: ${{ parameters.continueOnError }}
condition: ${{ parameters.condition }}
inputs:
targetType: 'inline'
script: >-
$(runImageBuilderBaseCmd) ${{ parameters.linuxOnlyExtraDockerRunArgs }} $(imageBuilderImageName) ${{ parameters.args }}