Skip to content

Commit edc5fe4

Browse files
committed
Update azure-pipelines.yml for Azure Pipelines
1 parent dd8b42f commit edc5fe4

File tree

1 file changed

+50
-15
lines changed

1 file changed

+50
-15
lines changed

azure-pipelines.yml

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
11
trigger:
2-
- master
2+
branches:
3+
include:
4+
- master
35

46
pool:
5-
vmImage: ubuntu-latest
6-
7-
steps:
8-
- checkout: self
9-
displayName: 'Checkout Source'
10-
11-
- script: |
12-
echo $(SONAR_HOST_URL); sleep 10
13-
docker pull blacklocksec/code-scanner:latest
14-
docker run --rm -v $(Build.SourcesDirectory):/app -e SONAR_PROJECTKEY='azure-the-test' -e SONAR_HOST_URL=$(SONAR_HOST_URL) -e SONAR_TOKEN=$(SONAR_TOKEN) blacklocksec/code-scanner:latest
15-
displayName: 'Run Blacklock Code Scanner'
16-
env:
17-
SONAR_HOST_URL: $(SONAR_HOST_URL)
18-
SONAR_TOKEN: $(SONAR_TOKEN)
7+
vmImage: 'ubuntu-latest'
8+
9+
jobs:
10+
- job: BuildAndAnalyze
11+
displayName: 'Build and Analyze'
12+
steps:
13+
- checkout: self
14+
fetchDepth: 0 # Shallow clones should be disabled for better analysis
15+
16+
- task: JavaToolInstaller@0
17+
displayName: 'Set up JDK 17'
18+
inputs:
19+
versionSpec: '17'
20+
jdkArchitecture: 'x64'
21+
jdkSource: 'PreInstalled'
22+
23+
- task: Cache@2
24+
displayName: 'Cache SonarQube packages'
25+
inputs:
26+
key: 'sonar | "$(Agent.OS)"'
27+
path: $(HOME)/.sonar/cache
28+
29+
- task: Cache@2
30+
displayName: 'Cache Gradle packages'
31+
inputs:
32+
key: 'gradle | "$(Agent.OS)" | "**/*.gradle"'
33+
path: $(HOME)/.gradle/caches
34+
35+
- script: |
36+
docker pull blacklocksec/code-scanner:staging
37+
displayName: 'Pull Blacklock Code Scanner Docker Image'
38+
39+
- script: |
40+
docker run --rm -v $(Build.SourcesDirectory):/app -v /bl_reports/:/bl_reports/ -e SCAN_MODE="1" blacklocksec/code-scanner:staging; cat /bl_reports/sonar_trivy.json
41+
displayName: 'Run Blacklock Code Scanner'
42+
43+
- script: |
44+
45+
ls -lah /bl_reports/; sh gradlew build sonar --info \
46+
-Dsonar.projectKey="gitlab_person" \
47+
-Dsonar.token=$(SONAR_TOKEN) \
48+
-Dsonar.host.url=$(SONAR_HOST_URL) \
49+
-Dsonar.externalIssuesReportPaths=$(echo /bl_reports/sonar_trivy.json /bl_reports/sonar_semgrep.json | tr ' ' '\n' | awk '{if (system("[ -f " $0 " ]") == 0) print $0}' | paste -sd ",")
50+
displayName: 'Build and analyze'
51+
env:
52+
SONAR_TOKEN: $(SONAR_TOKEN)
53+
SONAR_HOST_URL: $(SONAR_HOST_URL)

0 commit comments

Comments
 (0)