-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
111 lines (92 loc) · 3.31 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
# 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:
- main
#pool:
# vmImage: ubuntu-latest
variables:
imageName: 'rcmendes/quarkus-redis'
serviceConnection: 'quayServiceConnection'
roxCentralEndpoint: 'acs-data-clsuo50j3h5s6dovaj90.acs.rhcloud.com:443'
resources:
repositories:
- repository: ManifestsRepo
type: github
endpoint: github.com_raffamendes
name: raffamendes/helm-charts
ref: main
stages:
- stage: 'CI'
displayName: 'Build and Push Image'
jobs:
- job: 'Build'
displayName: 'Build and Push Image'
pool:
vmImage: ubuntu-latest
steps:
- task: Maven@3
inputs:
options: '-DskipTests'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '17'
jdkArchitectureOption: 'x64'
goals: 'package'
- task: Docker@2
displayName: Build from Red Hat Universal Base Image
inputs:
command: buildAndPush
containerRegistry: $(serviceConnection)
repository: $(imageName)
Dockerfile: src/main/docker/Dockerfile.jvm
buildContext: $(System.DefaultWorkingDirectory)
tags: $(Build.SourceVersion)
- script: |
set +x
export NO_COLOR="True"
curl -k -L -H "Authorization: Bearer $ROX_API_TOKEN" "https://"$(roxCentralEndpoint)"/api/cli/download/roxctl-linux" --output ./roxctl
chmod +x ./roxctl
IMAGE=$(docker images | grep quay | awk '{print $1}')
TAG=$(docker images | grep quay | awk '{print $2}')
./roxctl image scan --insecure-skip-tls-verify \
-e "$(roxCentralEndpoint)" --image "$IMAGE:$TAG" \
--output "json"
env:
ROX_API_TOKEN: $(RoxApiToken)
displayName: "ACS Image Scan"
- script: |
set +x
export NO_COLOR="True"
curl -k -L -H "Authorization: Bearer $ROX_API_TOKEN" "https://"$(roxCentralEndpoint)"/api/cli/download/roxctl-linux" --output ./roxctl
chmod +x ./roxctl
IMAGE=$(docker images | grep quay | awk '{print $1}')
TAG=$(docker images | grep quay | awk '{print $2}')
./roxctl image check --insecure-skip-tls-verify \
-e "$(roxCentralEndpoint)" --image "$IMAGE:$TAG" \
--output "json"
env:
ROX_API_TOKEN: $(RoxApiToken)
displayName: "ACS Image Check"
- stage: 'CD'
displayName: "Update the manifest repo"
dependsOn: 'CI'
jobs:
- job: 'CI'
displayName: 'Update manifest repo'
pool:
vmImage: ubuntu-latest
steps:
- checkout: ManifestsRepo
persistCredentials: true
- script: |
apk add py3-pip jq
pip install yq
yq -iy '.image.tag = "$(Build.SourceVersion)"' charts/quarkus-redis/values.yaml
git config --global user.email "[email protected]"
git config --global user.name "Azure Pipelines"
git add .
git commit -m "[Azure Pipelines] Updating image tag"
git pull --ff --no-edit
git push origin HEAD:main
displayName: 'Updating helm repo'