-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull-request-pipeline.yml
101 lines (94 loc) · 3.85 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
trigger:
- none
pr:
- master
- R4B
variables:
- group: ZULIP_VAR_GROUP
- group: SSH_UPLOAD
jobs:
- job: setupEnvironment
steps:
- task: Bash@3
displayName: 'Download java sdk'
inputs:
targetType: 'inline'
script: 'wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk/8u262-b10/openlogic-openjdk-8u262-b10-linux-x64.tar.gz -O $(Build.ArtifactStagingDirectory)/java8.tar.gz'
- task: JavaToolInstaller@0
inputs:
versionSpec: "8"
jdkArchitectureOption: x64
jdkSourceOption: LocalDirectory
jdkFile: "$(Build.ArtifactStagingDirectory)/java8.tar.gz"
jdkDestinationDirectory: ""
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo JAVA_HOME set to -> $JAVA_HOME
echo JAVA_HOME_8_X64 set to -> $JAVA_HOME_8_X64
echo which java returns
which java
- job: buildAndPublishSpecification
steps:
# Trigger a publish to test if all changes produce a valid, publishable java implementation of the specification
- task: Gradle@2
inputs:
gradleWrapperFile: 'gradlew'
javaHomeOption: 'JDKVersion'
publishJUnitResults: false
tasks: 'publish --stacktrace'
# 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
TARGET_DIRECTORY=$(echo "$(System.PullRequest.SourceBranch)" | sed -r 's/\//_/g')
echo "Publishing to target $TARGET_DIRECTORY"
tar czf - * | ssh -i $(Agent.TempDirectory)/deploy.rsa -p 2222 $(BUILD_FHIR_ORG_USERNAME)@build.fhir.org ./publish $TARGET_DIRECTORY
# 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.
- job: successNotification
dependsOn: buildAndPublishSpecification
condition: succeeded()
timeoutInMinutes: 5
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
TARGET_DIRECTORY=$(echo "$(System.PullRequest.SourceBranch)" | sed -r 's/\//_/g')
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 $TARGET_DIRECTORY :thumbs_up:! [build logs](https://dev.azure.com/fhir-pipelines/fhir-publisher/_build/results?buildId=$(Build.BuildNumber)&_a=summary&view=logs)
Published webpage can be viewed [here](https://build.fhir.org/branches/$TARGET_DIRECTORY)
"
- job: failureNotification
dependsOn: buildAndPublishSpecification
condition: failed()
timeoutInMinutes: 5
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
TARGET_DIRECTORY=$(echo "$(System.PullRequest.SourceBranch)" | sed -r 's/\//_/g')
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 $TARGET_DIRECTORY :thumbs_down:! [build logs](https://dev.azure.com/fhir-pipelines/fhir-publisher/_build/results?buildId=$(Build.BuildNumber)&_a=summary&view=logs)
"