First acquaintance with jenkins pipeline

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”        } else {           bat(/” {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”        } else {           bat(/” {mvnHome}\bin\mvn” sonar:sonar/)
}}
}
sleep(10)
stage(‘Quality Gate’) {
timeout(3) {
def qg = waitForQualityGate()
echo “—before qg: q g . s t a t u s i f ( q g . s t a t u s ! = O K ) e r r O r not yet Pass pass S O n a r q u b e of generation code quality quantity threshold check check Please and Time build change f a i l u r e : $ q g . s t a t u s e c h O a f t e r q g : {qg.status}—”
}
}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325699837&siteId=291194637