-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
69 lines (64 loc) · 2.13 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
String getDiscordMessage() {
def msg = "**Status:** " + currentBuild.currentResult.toLowerCase() + "\n**Branch:** ${BRANCH_NAME}\n**Changes:**\n"
if (!currentBuild.changeSets.isEmpty()) {
currentBuild.changeSets.first().getLogs().each {
msg += "- `" + it.getCommitId().substring(0, 8) + "` *" + it.getComment().substring(0, Math.min(64, it.getComment().length() - 1)) + (it.getComment().length() - 1 > 64 ? "..." : "") + "*\n"
}
} else {
msg += "- no changes\n"
}
msg += "\n**Artifacts:**\n"
currentBuild.rawBuild.getArtifacts().each {
msg += "- [" + it.getDisplayPath() + "](" + env.BUILD_URL + "artifact/" + it.getHref() + ")\n"
}
return msg.length() > 2048 ? msg.substring(0, 2045) + "..." : msg
}
pipeline {
agent any
tools {
git "Default"
jdk "jdk8"
}
options {
buildDiscarder(logRotator(artifactNumToKeepStr: '5'))
}
stages {
stage("Prepare Workspace") {
steps {
sh "./gradlew setupCiWorkspace"
}
}
stage("Build") {
steps {
sh "./gradlew build"
}
post {
success {
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
}
}
}
stage("Deploy") {
when {
branch "master"
}
steps {
sh "./gradlew publish"
}
}
}
post {
always {
sh "./gradlew --stop"
deleteDir()
withCredentials([string(credentialsId: "valkyrien_skies_discord_webhook", variable: "discordWebhook")]) {
discordSend thumbnail: "https://static.miraheze.org/valkyrienskieswiki/6/63/Logo_128.png",
result: currentBuild.currentResult,
description: getDiscordMessage(),
link: env.BUILD_URL,
title: "vw-world:${BRANCH_NAME} #${BUILD_NUMBER}",
webhookURL: "${discordWebhook}"
}
}
}
}