-1

Recently I've got a Jenkins Job which run a couple of tests and generate a string report.

I want to send it to informers but I cannot find the way to achieve the goal.

Let me show you what I want to do.

enter image description here

while executing this command, it'll do some calculation and generate a string output.

And I want to use this string here, (get the string and use it as ${REPORT} in content box) enter image description here

Is there any way to do that?

Appreciate!

Heath Yang
  • 471
  • 1
  • 4
  • 10
  • I don't understand your question. You got a Jenkins Job that generate the string report, but then you are asking again whether you can generate the string report on Jenkins? – Victor Wong Sep 27 '18 at 09:56
  • Please be more specific, exactly what you want. Do you want an e-mail report of your job or are you looking for a specific output or ... – JGK Sep 27 '18 at 21:06
  • @JGK Sorry for the inconvenience, I've update the description. – Heath Yang Sep 28 '18 at 02:57
  • @VictorWong Sorry for the inconvenience, I've update the description. – Heath Yang Sep 28 '18 at 02:57

2 Answers2

0

I would suggest doing this with a declarative pipeline. Assign the command output to $report then do whatever you want with it further.

pipeline {
    agent any
    stages {
        stage ('Generate report') {
            steps {
                script {
                    report = bat(script: "cd analysis && npm run jenkins-update && npm run jenkins-report", returnStatus: true)
                    // Do whatever you want with $report such as attaching it in an email
                }
            }
        }
    }
}
Victor Wong
  • 3,457
  • 1
  • 18
  • 31
0

You can achieve this with the Email-ext plugin. A good start are the recipes on the plugin website.

See also this SO post.

JGK
  • 3,710
  • 1
  • 21
  • 26