Browse Source

use emailext in steps

master
artoo 1 year ago
parent
commit
17eac66782
  1. 53
      src/org/artixlinux/RepoPackage.groovy
  2. 25
      vars/NotifyBuildFailure.groovy
  3. 26
      vars/NotifyBuildSuccess.groovy
  4. 20
      vars/NotifyRepoAdd.groovy
  5. 20
      vars/NotifyRepoRemove.groovy

53
src/org/artixlinux/RepoPackage.groovy

@ -133,59 +133,6 @@ class RepoPackage implements Serializable {
config.tools.cmdRepoRemove += " -d ${config.src.repoRemoveName} ${fileArgs}"
}
private String getBuildMailSubject(String msg) {
return "[${config.src.repoAddName}] ${msg}: ${info.pkgbase.name}"
}
private String getBuildMailBody(String msg, String url) {
return """
<p><strong>${msg}</strong></p>
<p>Build: ${config.src.repoPath}</p>
<p>Name:</p>
<p>${info.pkgbase.name}</p>
<p>author: ${config.author.name}</p>
<p>email: ${config.author.email}</p>
<p><a href=${url}>${url}</a></p>
"""
}
void sendBuildMail(String msg, String sendto, String url) {
steps.emailext (
mimeType: config.notify.mime,
body: getBuildMailBody(msg, url),
subject: getBuildMailSubject(msg),
to: sendto,
attachLog: false,
attachmentsPattern: "*.log",
compressLog: true
)
}
private String getRepoMailSubject(String msg, String action) {
return "[${action}] ${msg}: ${info.pkgbase.name}"
}
private String getRepoMailBody(String msg, String repo) {
return """
<p><strong>${msg}</strong></p>
<p>Repo: ${repo}</p>
<p>Packages:</p>
<p>${info.files.join('\n')}</p>
<p>author: ${config.author.name}</p>
<p>email: ${config.author.email}</p>
"""
}
void sendRepoMail(String msg) {
steps.emailext (
mimeType: config.notify.mime,
body: getRepoMailBody(msg, config.src.repoAddName),
subject: getRepoMailSubject(msg, config.src.repoAddName),
to: config.notify.repos,
attachLog: false
)
}
void initialize(String commit) {
loadConfig()

25
vars/NotifyBuildFailure.groovy

@ -1,10 +1,31 @@
#!/usr/bin/env groovy
def call(def pkg) {
pkg.sendBuildMail('Failure', pkg.config.notify.fails, BUILD_URL)
archiveArtifacts(
allowEmptyArchive: true,
artifacts: "${pkg.config.arch}**/*.log"
)
String msg = 'Failure'
String subject = "[${pkg.config.src.repoAddName}] ${msg}: ${pkg.info.pkgbase.name}"
String body = """
<p><strong>${msg}</strong></p>
<p>Build: ${pkg.config.src.repoPath}</p>
<p>Name:</p>
<p>${pkg.info.pkgbase.name}</p>
<p>author: ${pkg.config.author.name}</p>
<p>email: ${pkg.config.author.email}</p>
<p><a href=${BUILD_URL}>${BUILD_URL}</a></p>
"""
emailext (
mimeType: pkg.config.notify.mime,
subject: subject,
body: body,
to: pkg.config.notify.fails,
attachLog: false,
attachmentsPattern: "${pkg.config.arch}**/*.log",
compressLog: true
)
}

26
vars/NotifyBuildSuccess.groovy

@ -4,11 +4,31 @@ def call(def pkg) {
sh "${pkg.config.tools.cmdSign}"
pkg.config.actions.isAdd = true
// maybe only send namcap & check logs?
// pkg.sendBuildMail('Success', pkg.config.notify.builds, BUILD_URL)
archiveArtifacts(
allowEmptyArchive: true,
artifacts: "${pkg.config.arch}**/*.log"
)
// String msg = 'Success'
// String subject = "[${pkg.config.src.repoAddName}] ${msg}: ${pkg.info.pkgbase.name}"
//
// String body = """
// <p><strong>${msg}</strong></p>
// <p>Build: ${pkg.config.src.repoPath}</p>
// <p>Name:</p>
// <p>${pkg.info.pkgbase.name}</p>
// <p>author: ${pkg.config.author.name}</p>
// <p>email: ${pkg.config.author.email}</p>
// <p><a href=${BUILD_URL}>${BUILD_URL}</a></p>
// """
//
// emailext (
// mimeType: pkg.config.notify.mime,
// subject: subject,
// body: body,
// to: pkg.config.notify.builds,
// attachLog: false,
// attachmentsPattern: "${pkg.config.arch}**/*.log",
// compressLog: true
// )
}

20
vars/NotifyRepoAdd.groovy

@ -1,5 +1,23 @@
#!/usr/bin/env groovy
def call(def pkg) {
pkg.sendRepoMail('repo-add')
String msg = 'repo-add'
String subject = "[${msg}] ${pkg.config.src.repoAddName}: ${pkg.info.pkgbase.name}"
String body = """
<p><strong>${msg}</strong></p>
<p>Repo: ${pkg.config.src.repoAddName}</p>
<p>Packages:</p>
<p>${pkg.info.files.join('\n')}</p>
<p>author: ${pkg.config.author.name}</p>
<p>email: ${pkg.config.author.email}</p>
<p><a href=${BUILD_URL}>${BUILD_URL}</a></p>
"""
emailext (
mimeType: pkg.config.notify.mime,
subject: subject,
body: body,
to: pkg.config.notify.repos,
attachLog: false
)
}

20
vars/NotifyRepoRemove.groovy

@ -1,5 +1,23 @@
#!/usr/bin/env groovy
def call(def pkg) {
pkg.sendRepoMail('repo-remove')
String msg = 'repo-remove'
String subject = "[${msg}] ${pkg.config.src.repoRemoveName}: ${pkg.info.pkgbase.name}"
String body = """
<p><strong>${msg}</strong></p>
<p>Repo: ${pkg.config.src.repoRemoveName}</p>
<p>Packages:</p>
<p>${pkg.info.files.join('\n')}</p>
<p>author: ${pkg.config.author.name}</p>
<p>email: ${pkg.config.author.email}</p>
<p><a href=${BUILD_URL}>${BUILD_URL}</a></p>
"""
emailext (
mimeType: pkg.config.notify.mime,
subject: subject,
body: body,
to: pkg.config.notify.repos,
attachLog: false
)
}

Loading…
Cancel
Save