forked from IHTSDO/snap2snomed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
113 lines (108 loc) · 4.5 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
name: snap2snomed-$(Date:yyyyMMdd)$(Rev:.r)_$(SourceBranchName)
trigger:
branches:
include:
- '*'
pr: none
pool:
vmImage: ubuntu-20.04
variables:
mavenCache: $(Pipeline.Workspace)/.m2/repository
mavenOptions: '-Dmaven.repo.local=$(mavenCache)'
trivyVersion: 0.27.1
stages:
- stage: build
displayName: Build
jobs:
- job: build
timeoutInMinutes: 45
displayName: Build
steps:
- task: Cache@2
displayName: Cache Maven local repo
inputs:
key: 'maven | "$(Agent.OS)" | **/pom.xml'
restoreKeys: |
maven | "$(Agent.OS)"
maven
path: $(mavenCache)
- task: DownloadSecureFile@1
name: mavenSettings
displayName: 'Download Maven settings.xml'
inputs:
secureFile: 'agent-settings.xml'
- task: npmAuthenticate@0
inputs:
workingFile: ui/snapclient/.npmrc
- task: Maven@3
displayName: Build
inputs:
mavenPomFile: 'pom.xml'
options: '-B -s $(mavenSettings.secureFilePath) -Ddocker.registry.host=$(dockerRegistry) -Ddocker.repository=$(registryPath) -Djib.to.tags=$(Build.SourceBranchName),$(Build.BuildNumber)'
mavenFeedAuthenticate: true
mavenOptions: ' $(mavenOptions)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.17'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/*/TEST*-*.xml'
goals: 'clean verify -Pazure-devops -DskipUITests=$(skipUITests)'
- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage
inputs:
enabled: $(enableCodeCoverage)
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '**/target/site/jacoco/jacoco.xml'
reportDirectory: '**/target/site/jacoco'
additionalCodeCoverageFiles: '**/target/jacoco.exec'
- script: |
sudo apt-get install rpm
wget https://github.com/aquasecurity/trivy/releases/download/v$(trivyVersion)/trivy_$(trivyVersion)_Linux-64bit.deb
sudo dpkg -i trivy_$(trivyVersion)_Linux-64bit.deb
trivy -v
displayName: 'Download and install Trivy'
- task: CmdLine@2
displayName: "Run trivy scan on snap2snomed"
inputs:
script: |
trivy image --exit-code 0 --severity LOW,MEDIUM --security-checks vuln --timeout 15m $(dockerRegistry)/$(registryPath):$(Build.BuildNumber)
trivy image --exit-code 1 --severity HIGH,CRITICAL --security-checks vuln --timeout 15m $(dockerRegistry)/$(registryPath):$(Build.BuildNumber)
- script: |
export VERSION=`git rev-parse --short=7 HEAD` && \
yarn exec sentry-cli releases new $VERSION && \
yarn exec sentry-cli releases set-commits $VERSION -- --auto --ignore-missing && \
yarn exec sentry-cli releases files $VERSION upload-sourcemaps ../target/site
displayName: Notify Sentry of release
workingDirectory: $(System.DefaultWorkingDirectory)/ui/snapclient
env:
SENTRY_ORG: $(sentryOrg)
SENTRY_PROJECT: $(sentryProject)
SENTRY_AUTH_TOKEN: $(sentryAuthToken)
- task: Docker@2
condition: succeeded()
displayName: Push image
inputs:
containerRegistry: $(serviceConnection)
repository: $(registryPath)
command: push
tags: |
$(Build.SourceBranchName)
- task: Docker@2
condition: contains(variables['build.sourceBranch'], 'refs/heads/main')
displayName: Push image
inputs:
containerRegistry: $(serviceConnection)
repository: $(registryPath)
command: push
tags: |
$(Build.BuildNumber)
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/ui/target/site'
artifact: 'snap2snomed-ui'
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/terraform'
artifact: 'snap2snomed-terraform'
publishLocation: 'pipeline'