Use the jenkins pipeline plugin to build a job, mainly: pull code from gitlab - compile - sonar analysis - quality gate to determine whether it passes the quality valve The
script is as follows:
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git branch: ”, credentialsId: ”, url: ”
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'maven'
}
stage('Build') {
// Run the maven build
if (isUnix()) {
sh "'
{mvnHome}\bin\mvn” clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true/)
}
}
stage(‘Sonar’) {
withSonarQubeEnv(‘sonar’){
if (isUnix()) {
sh “’
{mvnHome}\bin\mvn” sonar:sonar/)
}}
}
sleep(10)
stage(‘Quality Gate’) {
timeout(3) {
def qg = waitForQualityGate()
echo “—before qg:
{qg.status}—”
}
}
}
First acquaintance with jenkins pipeline
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325699837&siteId=291194637
Recommended
Ranking