Jenkinsfile CPS错误

时间:2017-05-30 17:51:21

标签: jenkins jenkins-pipeline

以下是我的Jenkins文件。

构建将正常进行,直到生成错误结束。

我对Scripted管道不太熟悉,知道如何继续?

我的猜测是我错误地将引用变量用于docker容器?

提到Sandbox,我是否可以调用stop方法?

   node {

   checkout scm

    docker.withRegistry('http:localhost:5000') {



         try {
            stage 'Acquire HBASE Image'
            def hbase = docker.image('hbase-1.1.2').run()
            docker.image('jenkins-java').inside("--link=${hbase.id}:hbase"){




                checkout scm
                stage 'Build'
                sh 'gradle build'

                stage 'Test'
                sh 'gradle test'

                stage 'Publish Test Results'
                junit 'build/test-results/*.xml'

                stage 'Build Jar and Show Deps'
                sh 'gradle dependencies'
                sh 'gradle shadowJar'

                stage 'Integration Test'
                   withEnv(['METRICS_BATCHSIZE=10','METRICS_ZOOKEEPER_QUOROM=hbase:2181']){


                    sh 'java -jar build/libs/$(ls ./build/libs/ | grep .jar) migrate'
                    sh 'gradle integrationTest'

                   }

                stage 'Publish Integration Results'
                junit 'build/test-results/*.xml'
            }

        }
        finally {

            hbase.stop()

        }
}

}

错误是

Could not update commit status, please check if your scan credentials    belong to a member of the organization or a collaborator of the repository and repo:status scope is selected

 groovy.lang.MissingPropertyException: No such property: hbase for class: groovy.lang.Binding
Possible solutions: class
at groovy.lang.Binding.getVariable(Binding.java:63)
at      org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:46)
at org.jenkinsci.plugins.docker.workflow.Docker.withRegistry(jar:file:/var/lib/jenkins/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow

1 个答案:

答案 0 :(得分:0)

当我开始将文件视为编程语言构造时,答案很清楚。

解决方案是宣布

.col-md-6 {
  width: 100%;
  text-align: center;
在try / finally块开始之前

,以便声明变量并在finally块的范围内。