forked from AErmie/DevSecOps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sec-trivy-pipeline.yml
54 lines (48 loc) · 1.79 KB
/
sec-trivy-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
trigger: none
pool:
vmImage: 'ubuntu-latest'
variables:
pathToDockerFile: 'Dockerfile'
ACRConnectionName: 'AzureContainerRegistry-DevSecOps'
ACRLoginServer: 'adinermieacr.azurecr.io'
ACRRepository: 'eshoponweb'
stages:
- stage: QualityCheckStage
displayName: Quality Check Stage
jobs:
- job: TrivyJob
displayName: Run AquaSec Trivy Scan
steps:
- task: Docker@2
displayName: Build Container
inputs:
containerRegistry: $(ACRConnectionName)
repository: $(ACRRepository)
command: build
Dockerfile: $(pathToDockerFile)
tags: |
$(Build.BuildId)
- bash: |
docker run -d -p 5000:8080 $(ACRLoginServer)/$(ACRRepository):$(Build.BuildId)
displayName: 'Run App in Docker Container'
- script: |
docker pull aquasec/trivy:latest
docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock \
--volume $HOME/Library/Caches:/root/.cache/ --name Trivy aquasec/trivy:latest --format template --template "@contrib/junit.tpl" --output junit-report.xml \
$(ACRLoginServer)/$(ACRRepository):$(Build.BuildId)
docker cp $HOME/Library/Caches/junit-report.xml $(System.DefaultWorkingDirectory)/
echo "Trivy DIR Content"
cd $HOME/Library/Caches/trivy
ls -la
echo "Default Working DIR Content"
cd $(System.DefaultWorkingDirectory)
ls -la
displayName: Run AquaSec Trivy
- task: PublishTestResults@2
displayName: Publish Test Results
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/junit-report.xml'
mergeTestResults: false
failTaskOnFailedTests: true
testRunTitle: 'AquaSec Trivy'