Last active
March 20, 2023 06:50
-
-
Save iskandarsaleh/9c5e3df1607365fb3bd8de51f3c9e22c to your computer and use it in GitHub Desktop.
Jenkins Integration with Git Maven And SonarQube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
manage jenkins | |
global tools configuration | |
maven | |
name "project maven" | |
maven home "path maven project" | |
back to jenkins | |
build | |
add maven version | |
goal clean package | |
build now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
login to jenkins | |
enter item name | |
freetyle project jenkins | |
klik ok | |
go to repo github | |
copy path | |
back to jenkins | |
configure | |
go to source code management | |
repository copy link url github | |
build | |
goal => clean package | |
save | |
build now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
stage('SCM Chekout'){ | |
https://github.com/iskandarsaleh/REST-API-by-Go | |
} | |
stage('Compile-Package'){ | |
//get maven home path | |
def mvnhome = tool name: 'maven-3', type: 'maven' | |
sh "${mvnhome}/bin/mvn package" | |
} | |
stage('SonarQube Analysis') { | |
def mvnhome = tool name: 'maven-3', type: 'maven' | |
withSonarQubeEnv('sonar') { | |
sh "${mvnHome}/bin/mvn sonar:sonar" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sonarcube scanner for maven => | |
node { | |
stage('SCM') { | |
git 'https://github.com/foo/bar.git' | |
} | |
stage('SonarQube analysis') { | |
withSonarQubeEnv('My SonarQube Server') { | |
// requires SonarQube Scanner for Maven 3.2+ | |
sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar' | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
manage jenkins | |
configure system | |
sonarqube server | |
add sonarqube => name ex. 'sonar-6' | |
login to server sonar qube => generate token ; provide a token ; copy token | |
back to jenkins | |
fill => name : sonar-6 ; server URL ; Server auth | |
save | |
go to repo | |
create jenkins file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment