Skip to content

Commit d81e446

Browse files
committed
Deploying to gh-pages from @ 72a3902 🚀
1 parent ca37b99 commit d81e446

3 files changed

Lines changed: 64 additions & 50 deletions

File tree

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tutorials/jenkins/sonarqube-jenkins/Jenkinsfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
def net = '' // Set the value to 'host' to use host networking.
1+
def attachJenkinsNetwork = true
2+
// If true, the pipeline will attach the SonarQube scanner to the same network
3+
// with Jenkins and SonarQube containers.
4+
5+
def scannerArgs = ''
26

37
pipeline {
48
agent any
59
stages {
610
stage ('Prepare') {
711
steps {
812
script {
9-
if (net == '') {
13+
if (attachJenkinsNetwork == true) {
1014
// Get the name of the network that Jenkins container is using.
11-
net = sh returnStdout: true, script: 'docker inspect $(hostname) -f \'{{ range $k, $v := .NetworkSettings.Networks }}{{ $k }}{{ end }}\''
15+
def net = sh returnStdout: true, script: 'docker inspect $(hostname) -f \'{{ range $k, $v := .NetworkSettings.Networks }}{{ $k }}{{ end }}\''
16+
scannerArgs = "--network ${net.trim()}"
1217
}
1318
}
1419
}
@@ -24,7 +29,7 @@ pipeline {
2429
docker {
2530
image 'sonarsource/sonar-scanner-cli'
2631
// In order to be able to use http://sonarqube:9000 we need to be in the same network as Jenkins and SonarQube are in.
27-
args "--net $net"
32+
args scannerArgs
2833
// To quarantee that the workspace contains the sources pulled in previous stage, we need to use the pipeline level workspace.
2934
reuseNode true
3035
}

0 commit comments

Comments
 (0)