-
Notifications
You must be signed in to change notification settings - Fork 180
/
pull-request-pipeline.yml
112 lines (104 loc) · 4.21 KB
/
pull-request-pipeline.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
trigger:
- none
pr:
- master
- R4B
variables:
- group: ZULIP_VAR_GROUP
- group: SSH_UPLOAD
- name: CI_BRANCH_DIRECTORY
value: $[ replace(variables['System.PullRequest.SourceBranch'], '/', '_') ]
jobs:
- job: setupEnvironment
steps:
- task: Bash@3
displayName: 'Download java sdk'
inputs:
targetType: 'inline'
script: 'wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk/11.0.15+10/openlogic-openjdk-11.0.15+10-linux-x64.tar.gz -O $(Build.ArtifactStagingDirectory)/java11.tar.gz'
- task: JavaToolInstaller@0
inputs:
versionSpec: "11"
jdkArchitectureOption: x64
jdkSourceOption: LocalDirectory
jdkFile: "$(Build.ArtifactStagingDirectory)/java11.tar.gz"
jdkDestinationDirectory: ""
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo JAVA_HOME set to -> $JAVA_HOME
echo JAVA_HOME_11_X64 set to -> $JAVA_HOME_11_X64
echo which java returns
which java
- job: buildAndPublishSpecification
dependsOn: setupEnvironment
timeoutInMinutes: 120
steps:
# This task reports the CI_BRANCH_DIRECTORY variable for re-use in caching and
# directory naming.
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo "CI_BRANCH_DIRECTORY: $(CI_BRANCH_DIRECTORY)"
# Trigger a publish to test if all changes produce a valid, publishable java implementation of the specification
- task: Cache@2
inputs:
key: tx-cache | $(CI_BRANCH_DIRECTORY)
path: $(HOME)/.fhir/tx-cache/HL7/fhir/$(CI_BRANCH_DIRECTORY)
displayName: Cache terminology cache directory
- task: Gradle@2
inputs:
gradleWrapperFile: 'gradlew'
javaHomeOption: 'JDKVersion'
publishJUnitResults: false
tasks: 'publish --stacktrace --refresh-dependencies'
# We need a valid ssh key to upload to build.fhir.org. This is stored in the azure pipelines secure filesystem.
# This step downloads the file for use within this job.
- task: DownloadSecureFile@1
displayName: 'Download ssh key.'
inputs:
secureFile: deploy.rsa
# This task takes the successfully built publish directory produced in the 'buildSpecification' job above and pushes it to
# build.fhir.org in a directory named after that branch that triggered this pull request.
- task: Bash@3
inputs:
targetType: 'inline'
script: |
cd publish
chmod 400 $(Agent.TempDirectory)/deploy.rsa
echo "Publishing to target $(CI_BRANCH_DIRECTORY)"
tar czf - * | ssh -o "StrictHostKeyChecking=no" -i $(Agent.TempDirectory)/deploy.rsa -p 2222 $(BUILD_FHIR_ORG_USERNAME)@build.fhir.org ./publish $(CI_BRANCH_DIRECTORY) || true
# In the case of a successful build and subsequent publish, we trigger a message to the committers/notifications channel
# on Zulip (chat.fhir.org) to let users know that the build is available.
- task: Bash@3
condition: succeeded()
inputs:
targetType: 'inline'
script: |
COMMIT_INFO=$(git log -n 1 --skip 1 --pretty='format:%B (%an)')
curl -X POST https://chat.fhir.org/api/v1/messages \
-u $(ZULIP_BOT_EMAIL):$(ZULIP_BOT_API_KEY) \
-d "type=stream" \
-d "to=$(ZULIP_STREAM_ID_COMMITTERS)" \
-d "subject=FHIR Build Status" \
-d $"content=PR Build success for branch $(CI_BRANCH_DIRECTORY) :thumbs_up:!
$COMMIT_INFO
[build logs](https://dev.azure.com/fhir-pipelines/fhir-publisher/_build/results?buildId=$(Build.BuildId)) | [published webpage](https://build.fhir.org/branches/$(CI_BRANCH_DIRECTORY))
"
- task: Bash@3
condition: failed()
inputs:
targetType: 'inline'
script: |
COMMIT_INFO=$(git log -n 1 --skip 1 --pretty='format:%B (%an)')
curl -X POST https://chat.fhir.org/api/v1/messages \
-u $(ZULIP_BOT_EMAIL):$(ZULIP_BOT_API_KEY) \
-d "type=stream" \
-d "to=$(ZULIP_STREAM_ID_COMMITTERS)" \
-d "subject=FHIR Build Status" \
-d $"content=Build failed for branch $(CI_BRANCH_DIRECTORY) :thumbs_down:!
$COMMIT_INFO
[build logs](https://dev.azure.com/fhir-pipelines/fhir-publisher/_build/results?buildId=$(Build.BuildId))
"