Browse Source

logs (#34)

add build-url in build mails

fix build artifacts

fix log file path

comment out BUILD_URL

fix syntax error

refactor notifications

Reviewed-on: #34
Co-Authored-By: artoo <artoo@artixlinux.org>
Co-Committed-By: artoo <artoo@artixlinux.org>
master
artoo 1 year ago
parent
commit
eb864a255c
  1. 3
      resources/org/artixlinux/config.yaml
  2. 52
      src/org/artixlinux/RepoPackage.groovy
  3. 12
      vars/NotifyBuildFailure.groovy
  4. 5
      vars/NotifyBuildSuccess.groovy
  5. 25
      vars/NotifyFail.groovy
  6. 25
      vars/NotifyFixed.groovy
  7. 20
      vars/NotifyRepoAdd.groovy
  8. 20
      vars/NotifyRepoRemove.groovy
  9. 5
      vars/PackagePipeline.groovy

3
resources/org/artixlinux/config.yaml

@ -58,4 +58,5 @@ actions:
notify:
builds: 'artix-builds@artixlinux.org'
fails: 'artix-build-failures@artixlinux.org'
fixes: 'artix-build-fixes@artixlinux.org'
repos: 'artix-repos@artixlinux.org'
mime: 'text/html'

52
src/org/artixlinux/RepoPackage.groovy

@ -133,6 +133,58 @@ 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: "${config.arch}**/*.log"
)
}
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()

12
vars/NotifyBuildFailure.groovy

@ -0,0 +1,12 @@
#!/usr/bin/env groovy
def call(def pkg) {
String msg = 'Failure'
pkg.sendBuildMail(msg, pkg.config.notify.fails, BUILD_URL)
archiveArtifacts(
allowEmptyArchive: true,
artifacts: "${pkg.config.arch}**/*.log"
)
}

5
vars/PostBuild.groovy → vars/NotifyBuildSuccess.groovy

@ -3,6 +3,11 @@
def call(def pkg) {
sh "${pkg.config.tools.cmdSign}"
pkg.config.actions.isAdd = true
String msg = 'build'
pkg.sendBuildMail(msg, pkg.config.notify.builds, BUILD_URL)
archiveArtifacts(
allowEmptyArchive: true,
artifacts: "${pkg.config.arch}**/*.log"

25
vars/NotifyFail.groovy

@ -1,25 +0,0 @@
#!/usr/bin/env groovy
def call(def pkg) {
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>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: 'text/html',
body: body,
subject: subject,
to: pkg.config.notify.fails,
attachLog: true
)
}

25
vars/NotifyFixed.groovy

@ -1,25 +0,0 @@
#!/usr/bin/env groovy
def call(def pkg) {
String msg = 'Fixed'
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>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: 'text/html',
body: body,
subject: subject,
to: pkg.config.notify.fixes,
attachLog: false
)
}

20
vars/NotifyRepoAdd.groovy

@ -3,23 +3,5 @@
def call(def pkg) {
String msg = 'repo-add'
String subject = "[${pkg.config.src.repoAddName}] ${msg}: ${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: 'text/html',
body: body,
subject: subject,
to: pkg.config.notify.builds,
attachLog: false
)
pkg.sendRepoMail(msg)
}

20
vars/NotifyRepoRemove.groovy

@ -3,23 +3,5 @@
def call(def pkg) {
String msg = 'repo-remove'
String subject = "[${pkg.config.src.repoRemoveName}] ${msg}: ${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: 'text/html',
body: body,
subject: subject,
to: pkg.config.notify.builds,
attachLog: false
)
pkg.sendRepoMail(msg)
}

5
vars/PackagePipeline.groovy

@ -25,9 +25,8 @@ def call(def pkg) {
BuildPkg(pkg)
}
post {
success { PostBuild(pkg) }
failure { NotifyFail(pkg) }
fixed { NotifyFixed(pkg) }
success { NotifyBuildSuccess(pkg) }
failure { NotifyBuildFailure(pkg) }
}
}
stage('Add') {

Loading…
Cancel
Save