-
Notifications
You must be signed in to change notification settings - Fork 28
/
azure-pipelines.yml
157 lines (143 loc) · 5.01 KB
/
azure-pipelines.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- master
stages:
# - stage: build
# pool:
# vmImage: ubuntu-latest
# jobs:
# - job: build
# steps:
# - task: Maven@3
# inputs:
# mavenPomFile: 'pom.xml'
# mavenOptions: '-Xmx3072m'
# javaHomeOption: 'JDKVersion'
# jdkVersionOption: '1.11'
# jdkArchitectureOption: 'x64'
# publishJUnitResults: true
# testResultsFiles: '**/surefire-reports/TEST-*.xml'
# goals: 'package'
- stage: uploadConfigStage
pool:
vmImage: ubuntu-latest
jobs:
- job: uploadComponentJob
steps:
- task: Bash@3
env:
BUILD_NUMBER : '$(Build.BuildNumber)'
BUILD_NUMBER_ARTIFACT: "BUILD_NO_PLACE_HOLDER"
CONFIG_FILE_PATH : '$(configFilePath)'
inputs:
targetType: 'inline'
script: |
# Write your commands here
echo updaing configfile with build number
echo "updating '$BUILD_NUMBER_ARTIFACT' with '$BUILD_NUMBER' in file $CONFIG_FILE_PATH"
ls -a
sudo sed -i -e "s/BUILD_NO_PLACE_HOLDER/'$BUILD_NUMBER'/g" $CONFIG_FILE_PATH
echo uploading and auto-validating configuration file: $CONFIG_FILE_PATH
cat $CONFIG_FILE_PATH
- task: ServiceNow-DevOps-Config-Agent-Upload-Config@1
name: uploadConfigTask
inputs:
connectedServiceName: '$(serviceConnectionName)'
applicationName: '$(AppName)'
uploadTarget: 'component'
configFile: '$(ConfigFilePath)'
namePath: '$(ComponentName)'
dataFormat: 'yaml'
autoValidate: true
autoCommit: true
- stage: GetSnapShotsByChangeSet
pool:
vmImage: ubuntu-latest
jobs:
- job: getSnapshotByChangeSetJob
variables:
changeSetId: $[stageDependencies.uploadConfigStage.uploadComponentJob.outputs['uploadConfigTask.changesetNumber'] ]
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo 'config task $UPLOAD_CONFIG_OUTPUT%'
echo '$CHANGE_SET_ID'
env:
CHANGE_SET : '$(changeSetId)'
UPLOAD_CONFIG_OUTPUT: "$[stageDependencies.uploadConfigStage.uploadComponentJob.outputs['uploadConfigTask']]"
- task: ServiceNow-DevOps-Config-Agent-Register-Pipeline@1
inputs:
connectedServiceName: '$(serviceConnectionName)'
changesetNumber: '$(changeSetId)'
applicationName: '$(AppName)'
- task: ServiceNow-DevOps-Config-Agent-Get-Snapshot@1
name: getSnapshotTask
inputs:
connectedServiceName: '$(serviceConnectionName)'
applicationName: '$(AppName)'
deployableName: '$(DeployableName)'
changeSetNumber: '$(changeSetId)'
- stage: GetSnapshotAndPublish
pool:
vmImage: ubuntu-latest
jobs:
- job: GetSnapshotAndPublishJob
variables:
snapShotObjects: $[stageDependencies.GetSnapShotsByChangeSet.getSnapshotByChangeSetJob.outputs['getSnapshotTask.snapshotObjects'] ]
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo 'GetSnapsho output %GET_SNAPSHOT_OUTPUT%'
echo '%CHANGE_SET%'
env:
GET_SNAPSHOT_OUTPUT: "$[stageDependencies.GetSnapShotsByChangeSet.getSnapshotByChangeSetJob.outputs['getSnapshotTask'] ]"
- task: ServiceNow-DevOps-Config-Agent-Get-Snapshot-Name@1
name : getSnapshotName
inputs:
deployableName: '$(DeployableName)'
script: |
function run(){
let name;
let deployableName = process.argv[2];
let jsonObj = $(snapShotObjects);
let size = jsonObj.result.length;
for( let i =0; i<size ;i++ ){
obj = jsonObj.result[i];
if(obj["deployable_id.name"].toLowerCase() == deployableName){
name = obj.name;
console.log(name); // This standard output of inline script is given as the task output
}
}
}
run();
- task: ServiceNow-DevOps-Config-Agent-Publish-Snapshot@1
inputs:
connectedServiceName: '$(serviceConnectionName)'
applicationName: '$(AppName)'
deployableName: '$(DeployableName)'
snapshotName: '$(getSnapshotName.snapshotName)'
- stage: ExportSnapshot
pool:
vmImage: ubuntu-latest
jobs:
- job: ExportSnapShot
variables:
snapshotName: $[stageDependencies.GetSnapshotAndPublish.GetSnapshotAndPublishJob.outputs['getSnapshotName.snapshotName'] ]
steps:
- task: ServiceNow-DevOps-Config-Agent-Export-Snapshot@1
inputs:
connectedServiceName: '$(serviceConnectionName)'
applicationName: '$(AppName)'
deployableName: '$(DeployableName)'
exporterName: '$(ExporterName)'
snapshotName: '$(snapshotName)'
saveFile: true
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)