forked from HL7/fhir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
master-branch-pipeline.yml
95 lines (86 loc) · 3.49 KB
/
master-branch-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
trigger:
- master
pr:
- none
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:
# 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
echo "Publishing to master"
tar czf - * | ssh -o "StrictHostKeyChecking=no" -i $(Agent.TempDirectory)/deploy.rsa -p 2222 $(BUILD_FHIR_ORG_USERNAME)@build.fhir.org ./publish master
# 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: |
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 master branch:thumbs_up:! [build logs](https://dev.azure.com/fhir-pipelines/fhir-publisher/_build/results?buildId=$(Build.BuildId)&view=results)
Published webpage can be viewed [here](https://build.fhir.org/)
"
- task: Bash@3
condition: failed()
inputs:
targetType: 'inline'
script: |
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 master branch :thumbs_down:! [build logs](https://dev.azure.com/fhir-pipelines/fhir-publisher/_build/results?buildId=$(Build.BuildId)&view=results)
"