-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
92 lines (80 loc) · 3.09 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!groovy
import groovy.json.JsonOutput
pipeline {
agent any
triggers {
pollSCM('H/15 * * * *') //polling for changes, here every 15 min
}
stages {
stage("Build") {
steps {
script {
env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim()
env.GIT_REPO_NAME = env.GIT_URL.replaceFirst(/^.*\/([^\/]+?).git$/, '$1')
env.REMOTE_DIR = "inthelifeofdoug.com/LudumDareBuilds/${env.GIT_REPO_NAME}/${env.BRANCH_NAME}/${BUILD_NUMBER}"
mqttNotification brokerUrl: 'tcp://home.inthelifeofdoug.com:1883',
credentialsId: 'mqttcreds',
message: getBeginMessage(),
qos: '2',
topic: "jenkins/${env.GIT_REPO_NAME}"
sh './gradlew clean'
sh './gradlew desktop:sprites'
sh './gradlew html:dist'
}
}
}
stage("UploadSSH") {
steps{
script {
sshPublisher(
publishers: [
sshPublisherDesc(
configName: "wxpick",
verbose: true,
transfers: [
sshTransfer(
sourceFiles: "html/build/dist/**",
removePrefix: "html/build/dist/",
remoteDirectory: "${env.REMOTE_DIR}",
)
])
])
}
}
}
}
post{
always {
mqttNotification brokerUrl: 'tcp://home.inthelifeofdoug.com:1883',
credentialsId: 'mqttcreds',
message: getMessage(),
qos: '2',
topic: "jenkins/${env.GIT_REPO_NAME}"
}
}
}
def getBeginMessage() {
def message = [
buildnumber: "${BUILD_NUMBER}",
status: "Starting",
title: "${env.GIT_REPO_NAME}",
project: "${currentBuild.projectName}",
duration: "${currentBuild.durationString}",
commitmessage: "${env.GIT_COMMIT_MSG}"
]
return JsonOutput.toJson(message)
}
def getMessage() {
def message = [
buildnumber: "${BUILD_NUMBER}",
status: "${currentBuild.currentResult}",
title: "${env.GIT_REPO_NAME}",
project: "${currentBuild.projectName}",
duration: "${currentBuild.durationString}",
commitmessage: "${env.GIT_COMMIT_MSG}"
]
if (currentBuild.resultIsBetterOrEqualTo("SUCCESS")) {
message.link = "http://${env.REMOTE_DIR}"
}
return JsonOutput.toJson(message)
}