Jenkins工作流远程装载程序错误

时间:2016-03-04 16:40:23

标签: jenkins groovy jenkins-workflow jenkins-pipeline

我试图通过Jenkins worklow的远程加载器插件导入远程脚本。我得到了一些奇怪的错误。当我将该脚本中的确切代码放入我的主工作流脚本时,它可以正常运行。

我还尝试从插件的github加载示例hello world脚本,该脚本没有问题。

这是远程脚本:

import org.rundeck.api.*
import org.rundeck.api.domain.*

import static org.rundeck.api.domain.RundeckExecution.ExecutionStatus.*

def version = '1.0'

def runJob(String jobId, Properties options) {
    RundeckClient rundeck = RundeckClient.builder().url("url").login("user", "password").version(11).build();
    RundeckExecution execution = rundeck.triggerJob(RunJobBuilder.builder().setOptions(options).setJobId(jobId).build());

    while (RUNNING.equals(execution.status)) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            break;
        }
        execution = rundeck.getExecution(execution.id);
    }

    echo 'RUNDECK EXECUTION OUTPUT'

    RundeckOutput rundeckOutput = rundeck.getJobExecutionOutput(execution.getId(), 0, 0, 0);
    if (null != rundeckOutput) {
        List<RundeckOutputEntry> logEntries = rundeckOutput.getLogEntries();
        if (null != logEntries) {
            String message = ""
            for (int i = 0; i < logEntries.size(); i++) {
                RundeckOutputEntry rundeckOutputEntry = (RundeckOutputEntry) logEntries.get(i);
                message += rundeckOutputEntry.message + "\n";
            }
            println message
        }
    }

    echo 'RUNDECK EXECUTION OUTPUT END'

    switch (execution.status) {
        case SUCCEEDED:
            println "Rundeck job ${execution.id} finished with success in ${execution.duration}"
            break;
        case FAILED:
            error 'Build failed!'
            break;
        default:
            break;
    }
}

return this;

我的主要脚本的相关部分如下所示:

stage name: 'rundeck'
    node() {
        def externalRundeck = fileLoader.fromGit('jenkins-workflow-scripts/rundeck',
                '<git url>',
                'master',
                '<credentials>',
                '');

        rundeck.runJob('d919822e-c72e-4adc-b4cc-98ff7c9d5a5e', new Properties())
}

构建的输出是:

[Pipeline] stage (rundeck)
Entering stage rundeck
Proceeding
[Pipeline] Allocate node : Start
Running on master in /home/jenkins/var/lib/jenkins/jobs/solrConfigWorklfow/workspace
[Pipeline] node {
[Pipeline] Allocate node : Start
Running on master in /home/jenkins/var/lib/jenkins/jobs/solrConfigWorklfow/workspace@2
[Pipeline] node {
[Pipeline] Change current directory : Start
Running in /home/jenkins/var/lib/jenkins/jobs/solrConfigWorklfow/workspace@2/libLoader
[Pipeline] dir {
[Pipeline] deleteDir
[Pipeline] echo
Checking out xxxxxxxxxxxx, branch=master
[Pipeline] git
Cloning the remote Git repository
Cloning repository xxxxxxxxxxx
 > git init /home/jenkins/var/lib/jenkins/jobs/solrConfigWorklfow/workspace@2/libLoader # timeout=10
Fetching upstream changes from xxxxxxxxxxxx
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username xxxxxxxxx # timeout=10
 > git config --local credential.helper store --file=/tmp/git834036599103203072.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://github.com/viogate/dev-support.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git config remote.origin.url xxxxxxxx # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url xxxxxx # timeout=10
Fetching upstream changes from xxxxxxxxxx
using .gitcredentials to set credentials
 > git config --local credential.username xxxxxxxx # timeout=10
 > git config --local credential.helper store --file=/tmp/git4826140835590679820.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://github.com/viogate/dev-support.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 522b47dc0761bde87b834966668b9458c6a5afd1 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 522b47dc0761bde87b834966668b9458c6a5afd1 # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
 > git checkout -b master 522b47dc0761bde87b834966668b9458c6a5afd1
[Pipeline] echo
Loading from jenkins-workflow-scripts/rundeck.groovy
[Pipeline] load (jenkins-workflow-scripts/rundeck.groovy)
[Pipeline] load {
[Pipeline] } //load
[Pipeline] deleteDir
[Pipeline] } //dir
[Pipeline] Change current directory : End
[Pipeline] } //node
[Pipeline] Allocate node : End
[Pipeline] } //node
[Pipeline] Allocate node : End
[Pipeline] End of Pipeline
groovy.lang.MissingPropertyException: No such property: rundeck for class: groovy.lang.Binding
    at groovy.lang.Binding.getVariable(Binding.java:62)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:185)
    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 com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:23)
    at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:17)
    at WorkflowScript.run(WorkflowScript:24)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:62)
    at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
    at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:54)
    at sun.reflect.GeneratedMethodAccessor1552.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
    at com.cloudbees.groovy.cps.Next.step(Next.java:58)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:106)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:277)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:77)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:186)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:184)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

感谢您的任何提示!

0 个答案:

没有答案