2017-11-30 16 views
0

私はジェンキンで障害が発生したときに電子メールを送信するためにジェンキンでステージを実装しようとしています。私はジェンキンスdocumentionに似何か作っ:Jenkins java.lang.NoSuchMethodError:ステップの中にそのようなDSLメソッド 'post'が見つかりません

#!/usr/bin/env groovy 

node { 

stage ('Send Email') { 

     echo 'Send Email' 

      post { 
       failure { 
        mail to: '[email protected]', 
         subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", 
         body: "Something is wrong with ${env.BUILD_URL}" 
       } 
      } 

     } 

} 

をしかし、私は常に、このエラーを取得:

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]

私はいくつか他の人が投稿しましたが、しかし、作られた提案は、私

答えて

2

私のために動作しませんでしたここでも同じ問題がありました。宣言型の例はたくさんありますが、スクリプト化されていないものはありません。それはほとんど解決策がないと信じるように導くが、それは理にかなっていない。

これは私のために働いています(これはtry/finallyなしで動作します)。

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

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

* EDIT:their documentationを見てみましょう...偶然私は、彼らがお勧め正確に何をやりました。 「Toggle Scripted Pipeline(Advanced)」リンクをクリックすると、そのリンクが表示されます。

関連する問題