|
1 | 1 | trigger:
|
2 |
| -- master |
| 2 | + branches: |
| 3 | + include: |
| 4 | + - master |
3 | 5 |
|
4 | 6 | 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