-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
51 lines (48 loc) · 1.91 KB
/
Jenkinsfile
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
pipeline {
agent any
options {
// This is required if you want to clean before build with the "Workspace Cleanup Plugin"
skipDefaultCheckout(true)
}
stages {
stage('SCM') {
steps {
// Clean before build using the "Workspace Cleanup Plugin"
cleanWs()
checkout scm
}
}
stage('Download Build Wrapper') {
steps {
powershell '''
$path = ".sonar/build-wrapper-win-x86.zip"
New-Item -ItemType directory -Path .sonar -Force
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile("<SonarQube URL>/static/cpp/build-wrapper-win-x86.zip", $path) <# Replace with your SonarQube server URL #>
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($path, ".sonar")
$env:Path += ";.sonar/build-wrapper-win-x86"
'''
}
}
stage('Build') {
steps {
powershell '''
New-Item -ItemType directory -Path build
cmake -S . -B build
build-wrapper-win-x86-64.exe --out-dir bw-output cmake --build build/ --config Release <# The build is clean thanks to the "cleanWs()" step #>
'''
}
}
stage('SonarQube Analysis') {
steps {
script {
def scannerHome = tool 'SonarScanner'; // Name of the SonarQube Scanner you created in "Global Tool Configuration" section
withSonarQubeEnv() {
powershell "${scannerHome}/bin/sonar-scanner"
}
}
}
}
}
}