Jenkins java.lang.NoSuchMethodError:在步骤之间找不到这样的DSL方法"post" [英] Jenkins java.lang.NoSuchMethodError: No such DSL method 'post' found among steps

查看:1943
本文介绍了Jenkins java.lang.NoSuchMethodError:在步骤之间找不到这样的DSL方法"post"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在jenkins上实现一个阶段,以在jenkins发生故障时发送电子邮件.我做了类似詹金斯纪录片的东西:

I'm trying to implement a stage on jenkins to send email when a failure is produced on jenkins. I made something similiar to the jenkins documention:

#!/usr/bin/env groovy

node {

stage ('Send Email') {

        echo 'Send Email'

            post {
                failure {
                    mail to: 'aa@bb.cc',
                         subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
                         body: "Something is wrong with ${env.BUILD_URL}"
                }
            }

        }

}

但是我总是会收到此错误:

But i always get this error:

java.lang.NoSuchMethodError:在这样的DSL方法"post"中找不到 步骤[存档,bat,构建,catchError,签出,deleteDir,dir, dockerFingerprintFrom,dockerFingerprintRun,echo,emailext, emailextrecipients,envVarsForTool,错误,fileExists,getContext, git,input,isUnix,library,libraryResource,load,mail,里程碑, 节点,并行,powershell,属性,publishHTML,pwd,readFile, readTrusted,resolveScm,重试,脚本,sh,sleep,stage,stash,step, svn,超时,时间戳,tm,工具,取消存档,取消隐藏, validateDeclarativePipeline,waitUntil,withContext,withCredentials, 使用DockerContainer,使用DockerRegistry,使用DockerServer,使用Env, wrap,writeFile,ws]或符号[all,allOf,always,ant, antFromApache,antOutcome,antTarget,any,anyOf,apiToken, 架构,archiveArtifacts,artifactManager,authorizationMatrix, batchFile,booleanParam,分支,buildButton,buildDiscarder, caseInsensitive,caseSensitive,证书,变更日志,变更集, 选择,choiceParam,cleanWs,时钟,云,命令,凭据, cron,crump,defaultView,demand,disableConcurrentBuilds,docker, dockerCert,dockerfile,downloadSettings,下游,哑,envVars, 环境,表达式,文件,fileParam,filePath,指纹, frameOptions,freeStyle,freeStyleJob,fromScm,fromSource,git, github,githubPush,gradle,headRegexFilter,headWildcardFilter, 超链接,超链接到模型,继承,inheritingGlobal, installSource,jacoco,jdk,jdkInstaller,jgit,jgitapache,jnlp, jobName,junit,label,lastDuration,lastFailure, lastGrantedAuthorities,lastStable,lastSuccess,legacy,legacySCM, 列表,本地,位置,logRotator,loginInUsersCanDoAnything, masterBuild,maven,maven3Mojos,mavenErrors,mavenMojos, mavenWarnings,modernSCM,myView,node,nodeProperties,nonInheriting, nonStoredPasswordParam,none,not,overrideIndexTriggers,panelStatus, 参数,密码,模式,管道模型,pipelinetriggers, plainText,插件,pollSCM,projectNamingStrategy,代理, queueItemAuthenticator,quietPeriod,remotingCLI,run,runParam, 日程安排,scmRetryCount,搜索,安全性,shell,skipDefaultCheckout, skipStagesAfterUnstable,slave,sourceRegexFilter, sourceWildcardFilter,sshUserPrivateKey,stackTrace,标准,状态, 字符串,stringParam,swapSpace,文本,textParam,tmpSpace, toolLocation,不安全,上游,用户名ColonPassword, usernamePassword,viewsTabBar,天气,withAnt,zfs,zip]或全局变量 [currentBuild,docker,env,params,pipeline,scm]

java.lang.NoSuchMethodError: No such DSL method 'post' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, input, isUnix, library, libraryResource, load, mail, milestone, node, parallel, powershell, properties, publishHTML, pwd, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tm, tool, unarchive, unstash, validateDeclarativePipeline, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, allOf, always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, architecture, archiveArtifacts, artifactManager, authorizationMatrix, batchFile, booleanParam, branch, buildButton, buildDiscarder, caseInsensitive, caseSensitive, certificate, changelog, changeset, choice, choiceParam, cleanWs, clock, cloud, command, credentials, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerCert, dockerfile, downloadSettings, downstream, dumb, envVars, environment, expression, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, fromScm, fromSource, git, github, githubPush, gradle, headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, inheriting, inheritingGlobal, installSource, jacoco, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobName, junit, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, myView, node, nodeProperties, nonInheriting, nonStoredPasswordParam, none, not, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, pollSCM, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, remotingCLI, run, runParam, schedule, scmRetryCount, search, security, shell, skipDefaultCheckout, skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter, sshUserPrivateKey, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, usernameColonPassword, usernamePassword, viewsTabBar, weather, withAnt, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]

我看到了其他人的帖子,但提出的建议对我没有用

I saw some others post, but the suggestion made did not work for me

推荐答案

我在这里遇到了同样的问题.有很多示例性的示例,而没有脚本的示例.它几乎使您相信没有解决方案,但这没有任何意义.

I was having the same problem here. Lots of examples for declarative... none for scripted. It almost leads you to believe that there is no solution, but that wouldn't make sense.

这对我有用(无需尝试/最后也可以使用-如果需要,也可以使用).

This worked for me (it works without the try/finally -- or catch if you want).

node {
    //some var declarations... or whatever

    try {
        //do some stuff, run your tests, etc.            
    } finally {
        junit 'build/test-results/test/*.xml'
    }
}

*查看其文档. .偶然地,我完全按照他们的建议做了.只需点击切换脚本管道(高级)"链接,您就会看到它.

* take a look at their documentation... accidentally I've done exactly what they recommend. Just click on the "Toggle Scripted Pipeline (Advanced)" link and you'll see it.

这篇关于Jenkins java.lang.NoSuchMethodError:在步骤之间找不到这样的DSL方法"post"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆