2

I want to send my Cucumber reports to Slack using Jenkins Declarative Pipeline. I have installed Cucumber+Slack+Notifier+Plugin.

With this code,

pipeline {
    agent any
    tools {
        maven 'M2'
        jdk 'JDK'
        nodejs 'NODEJS'
        //cucumberSendSlack 'cucumberSendSlack'
    }
    stages {
        stage('Start') {
            steps {
              bat 'mvn -v'
              cucumberSendSlack channel: 'slack-room-cicd', json: '$WORKSPACE/reports.json'

            }
        }
    }
    post {
     always {

      echo "Post Build"

    }
  }
}

It gives an error,

   No such DSL method 'cucumberSendSlack' found among steps

But I have installed the plugin and I was able to send the cucumber report using a Freestyle project.

enter image description here

Any idea of how to use the plugin in Declarative Pipeline?

*********** edit ***********

[Pipeline] {
[Pipeline] bat

Z:\Jenkins3\workspace\cucumbver>mvn -v 
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: C:\tools\apache-maven-3.3.9
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_151\jre
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
[Pipeline] cucumberSlackSend
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage`
John Seen
  • 701
  • 4
  • 15
  • 31

1 Answers1

2

You are calling a wrong method. The method cucumberSendSlack does not exist in the pipeline.

Checking the pipeline reference for this plugin the method is called: cucumberSlackSend.

Checking the plugin itself the example calls cucumberSendSlack. This is for a freestyle project though so if you want to use the plugin in your pipeline you have to call cucumberSlackSend.

Michael Kemmerzell
  • 4,802
  • 4
  • 27
  • 43
  • That's a good catch, `cucumberSlackSend` doesn't give any error. The pipeline is success but it does not send the report to Slack either. Updated my question with the new console response. – John Seen Jul 08 '19 at 14:16