Jenkins管道上的电子邮件插件

rfbsl7qr  于 2022-12-03  发布在  Jenkins
关注(0)|答案(1)|浏览(183)

我为Jenkins(2.176.3)安装了Email Extension Plugin(2.66),以便在Pipelines中使用,我正在尝试以下示例:https://medium.com/@gustavo.guss/jenkins-sending-email-on-post-build-938b236545d2

pipeline {
    environment {
        //This variable need be tested as string
        doError = '1'
    }

    agent any

    stages {
        stage('Error') {
            when {
                expression { doError == '1' }
            }
            steps {
                echo "Failure"
                error "failure test. It's work"
            }
        }

        stage('Success') {
            when {
                expression { doError == '0' }
            }
            steps {
                echo "ok"
            }
        }
    }
    post {
        always {
            echo 'I will always say Hello again!'

            emailext body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
                recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
                subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"

        }
    }
}

但我有以下错误:
执行始终发布条件时出错:java.lang.NoSuchMethodError:在步骤[版本号,接受GitLabMR,添加GitLabMRComment,存档,bat,构建,捕获错误, checkout ,删除目录,目录,停靠指纹来源,停靠指纹运行,echo,工具的环境变量,错误,文件存在,查找文件,获取上下文,...]中未找到此类DSL方法'电子邮件扩展'
此外,我无法配置插件本身,我不知道如何激活它,我重新启动Jenkins,系统并没有工作,管道语法编辑器不承认插件,任何建议?

qaxu7uf2

qaxu7uf21#

由于某种原因,我的Jenkins服务器的plugins文件夹中有文件:email-ext.jpi.disabled并删除该文件,管道语法编辑器开始识别插件本身......我不再收到“没有这样的DSL方法emailext”的消息
以马拉特在Jenkins Pipeline上发送邮件为例进行测试

相关问题