0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Jenkinsでメール送信

Last updated at Posted at 2025-05-09

前提:Email Extension Plugin導入済み

post {
    success {
        emailext (
            subject: "✅ Coverage Report for ${env.JOB_NAME} #${env.BUILD_NUMBER}",
            body: """Build successful!

- Job: ${env.JOB_NAME}
- Build: ${env.BUILD_URL}

Please see attached JaCoCo coverage report.
""",
            to: 'your-team@example.com',
            attachmentsPattern: 'build/reports/jacoco/**/index.html',
            mimeType: 'text/html'
        )
    }
    failure {
        emailext (
            subject: "❌ Build FAILED: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
            body: "Build failed: ${env.BUILD_URL}",
            to: 'your-team@example.com'
        )
    }
}

おまけ
ファイルをzipに固めて送信したい場合

sh 'zip -r build/reports/jacoco/all.zip build/reports/jacoco/'

emailext (
    subject: "Coverage Report ZIP",
    to: 'your-team@example.com',
    body: "See attached ZIP report",
    attachmentsPattern: 'build/reports/jacoco/all.zip'
)

windowsの場合

stage('Zip Coverage Reports') {
    steps {
        bat 'powershell Compress-Archive -Path build\\reports\\jacoco\\* -DestinationPath build\\reports\\jacoco\\all.zip -Force'
    }
}
post {
    success {
        emailext (
            subject: "✅ Coverage Report - ${env.JOB_NAME} #${env.BUILD_NUMBER}",
            body: """Coverage report attached as ZIP.

Build URL: ${env.BUILD_URL}
""",
            to: 'your-team@example.com',
            attachmentsPattern: 'build/reports/jacoco/all.zip'
        )
    }
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?