Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/tutorials/jenkins/sonarqube-jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
def net = '' // Set the value to 'host' to use host networking.

pipeline {
agent any
stages {
stage ('Prepare') {
steps {
script {
if (net == '') {
// Get the name of the network that Jenkins container is using.
net = sh returnStdout: true, script: 'docker inspect $(hostname) -f \'{{ range $k, $v := .NetworkSettings.Networks }}{{ $k }}{{ end }}\''
}
}
}
}
stage('Checkout') {
steps {
git "${GIT_URL}"
// Replace the git step below with step that pulls the repository you want to analyze.
git branch: 'main', url: 'https://github.com/cicd-tutorials/feedback.git'
}
}
stage('Analyze') {
agent {
docker {
image 'sonarsource/sonar-scanner-cli'
// In order to be able to use http://sonarqube:9000 we need to be in the same network as Jenkins and SonarQube are in.
args '--net jenkins_default'
args "--net $net"
// To quarantee that the workspace contains the sources pulled in previous stage, we need to use the pipeline level workspace.
reuseNode true
}
Expand Down