【发布时间】:2018-05-13 19:35:55
【问题描述】:
我正在尝试在 Jenkins 上实现一个阶段,以便在 Jenkins 发生故障时发送电子邮件。我做了一些类似于 Jenkins 文档的东西:
#!/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}"
}
}
}
}
但我总是得到这个错误:
java.lang.NoSuchMethodError: No such DSL method 'post' found between 步骤 [存档,bat,构建,catchError,结帐,deleteDir,目录, dockerFingerprintFrom、dockerFingerprintRun、echo、emailext、 emailextrecipients、envVarsForTool、错误、fileExists、getContext、 git,输入,isUnix,库,libraryResource,加载,邮件,里程碑, 节点、并行、powershell、属性、publishHTML、pwd、readFile、 readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, 超时, 时间戳, tm, 工具, unarchive, unstash, validateDeclarativePipeline、waitUntil、withContext、withCredentials、 withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] 或符号 [all, allOf, always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, 架构,archiveArtifacts,artifactManager,authorizationMatrix, batchFile, booleanParam, 分支, buildButton, buildDiscarder, 不区分大小写、区分大小写、证书、变更日志、变更集、 选择,choiceParam,cleanWs,时钟,云,命令,凭据, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerCert, dockerfile, downloadSettings, 下游, 哑, envVars, 环境、表达式、文件、fileParam、filePath、指纹、 框架选项,freeStyle,freeStyleJob,fromScm,fromSource,git, github,githubPush,gradle,headRegexFilter,headWildcardFilter, 超链接,超链接模型,继承,继承全局, installSource, jacoco, jdk, jdkInstaller, jgit, jgitapache, jnlp, 作业名称、junit、标签、lastDuration、lastFailure、 lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, 列表,本地,位置,logRotator,loggedInUsersCanDoAnything, masterBuild, 行家, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, myView, 节点, nodeProperties, nonInheriting, nonStoredPasswordParam, none, not, overrideIndexTriggers, paneStatus, 参数、密码、模式、管道模型、管道触发器、 纯文本、插件、pollSCM、projectNamingStrategy、代理、 queueItemAuthenticator,quietPeriod,remotingCLI,运行,runParam, 计划、scmRetryCount、搜索、安全、外壳、skipDefaultCheckout、 skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter、sshUserPrivateKey、stackTrace、标准、状态、 字符串,stringParam,swapSpace,文本,textParam,tmpSpace, toolLocation, unsecured, upstream, usernameColonPassword, usernamePassword、viewsTabBar、weather、withAnt、zfs、zip] 或 globals [currentBuild, docker, env, params, pipeline, scm]
我看到其他一些帖子,但提出的建议对我不起作用
【问题讨论】: