首页 > 解决方案 > Jenkins 管道无法正常工作的质量门状态

问题描述

在检查管道中的质量门状态时,出现以下错误。

管道代码如下

    stage('SonarQube') {
      // Run the maven build
            dir("xyz_7.6_Trunk/xyz-services"){


                sh ' mvn -f pom.xml clean install -Dapp.server=jboss org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar -Dsonar.host.url=http://10.11.135.66:9000 -Dsonar.scm.disabled=True -U' 

            }
            }

stage('Quality Gate') {
timeout(time: 1, unit: ‘HOURS’) {
def qg = waitForQualityGate()
if (qg.status != ‘OK’) {
error “Pipeline aborted due to quality gate failure: ${qg.status}”
}
}
}

错误日志如下。

java.lang.NoSuchMethodError: No such DSL method 'Time' 'HOURS' found among steps [acceptGitLabMR, addBadge, addErrorBadge, addGitLabMRComment, addHtmlBadge, addInfoBadge, addShortText, addWarningBadge, ansiblePlaybook, ansibleTower, ansibleVault, archive, artifactPromotion, bat, build, catchError, checkout, createSummary, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, dockerNode, ec2, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, gitChangelog, gitlabBuilds, gitlabCommitStatus, input, isUnix, junit, library, libraryResource, load, mail, milestone, nexusArtifactUploader, nexusPolicyEvaluation, nexusPublisher, node, parallel, powershell, properties, pwd, readFile, readTrusted, removeBadges,  

标签: jenkinsjenkins-pipelinejenkins-groovy

解决方案


如我所见,您使用脚本化管道,因此语法应该没问题。

timeout功能在Pipeline: Basic Steps插件(插件的一部分Pipeline)中实现。这就是为什么我认为您需要重新安装这些插件并且应该解决问题。无论如何,请再次检查该步骤的语法。timeout


推荐阅读