-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
100 lines (87 loc) · 3.24 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
93
94
95
96
97
98
99
100
def skipCiCheck
def SkipCI(number = "all") {
// Method copied from https://shenxianpeng.github.io/2022/10/jenkins-skip-ci/
def statusCodeList = []
String[] keyWords = ['ci skip', 'skip ci'] // add more keywords if need.
keyWords.each { keyWord ->
def statusCode = null
if (number == "all") {
statusCode = sh script: "git log --oneline --all | grep \'${keyWord}\'", returnStatus: true
} else {
statusCode = sh script: "git log --oneline -n ${number} | grep \'${keyWord}\'", returnStatus: true
}
statusCodeList.add(statusCode)
}
return statusCodeList.contains(0)
}
pipeline {
agent any
options {
githubProjectProperty(projectUrlStr: "https://github.com/SirBlobman/BlueSlimeCore")
}
environment {
DISCORD_URL = credentials('PUBLIC_DISCORD_WEBHOOK')
MAVEN_DEPLOY = credentials('MAVEN_DEPLOY')
HANGAR_API_KEY = credentials('HANGAR_API_KEY')
JDK8 = '/home/container/jdk/zulu8.78.0.19-ca-jdk8.0.412-linux_x64'
JDK16 = '/home/container/jdk/zulu16.32.15-ca-jdk16.0.2-linux_x64'
JDK17 = '/home/container/jdk/zulu17.50.19-ca-jdk17.0.11-linux_x64'
JDK21 = '/home/container/jdk/zulu21.34.19-ca-jdk21.0.3-linux_x64'
}
triggers {
githubPush()
}
tools {
jdk "JDK 21"
}
stages {
stage('Check CI Skip') {
steps {
script {
skipCiCheck = this.SkipCI('1')
}
}
}
stage("Gradle: Build") {
when {
expression { return !skipCiCheck }
}
steps {
withGradle {
script {
if (env.BRANCH_NAME == "main") {
sh("./gradlew --no-daemon --refresh-dependencies clean build publish publishAllPublicationsToHangar")
} else if (env.BRANCH_NAME.contains("dev")) {
sh("./gradlew --no-daemon --refresh-dependencies clean build publish")
} else {
sh("./gradlew --no-daemon --refresh-dependencies clean build")
}
}
}
}
}
}
post {
success {
script {
if (!skipCiCheck) {
archiveArtifacts artifacts: 'core/build/libs/BlueSlimeCore-*.jar', fingerprint: true
archiveArtifacts artifacts: 'bungeecord/core/build/libs/BlueSlimeBungeeCore-*.jar', fingerprint: true
}
}
}
always {
script {
if (!skipCiCheck) {
discordSend webhookURL: DISCORD_URL, title: "BlueSlimeCore", link: "${env.BUILD_URL}",
result: currentBuild.currentResult,
description: """\
**Branch:** ${env.GIT_BRANCH}
**Build:** ${env.BUILD_NUMBER}
**Status:** ${currentBuild.currentResult}""".stripIndent(),
enableArtifactsList: false, showChangeset: true
}
}
}
}
}