-
Notifications
You must be signed in to change notification settings - Fork 32
/
Jenkinsfile
70 lines (63 loc) · 2.61 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
/*
Required env: java 21, git
Required plugins: discord notifier
Required credentials: MODRINTH_PUBLISH_API_TOKEN, HANGAR_PUBLISH_API_TOKEN
*/
pipeline {
agent any
environment {
GRADLE_OPTS = '-Dorg.gradle.daemon=false'
}
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/FancyMcPlugins/FancyHolograms', branch: 'main'
}
}
stage('Build') {
steps {
sh 'chmod +x gradlew'
sh './gradlew clean shadowJar'
echo 'Built the plugin!'
}
}
stage('Deploy') {
steps {
// Load the secrets and make them available as environment variables
withCredentials([
string(credentialsId: 'MODRINTH_PUBLISH_API_TOKEN', variable: 'MODRINTH_PUBLISH_API_TOKEN'),
string(credentialsId: 'HANGAR_PUBLISH_API_TOKEN', variable: 'HANGAR_PUBLISH_API_TOKEN')
]) {
sh 'export MODRINTH_PUBLISH_API_TOKEN=${MODRINTH_PUBLISH_API_TOKEN} && ./gradlew modrinth'
echo 'Published to Modrinth!'
sh 'export HANGAR_PUBLISH_API_TOKEN=${HANGAR_PUBLISH_API_TOKEN} && ./gradlew publishAllPublicationsToHangar'
echo 'Published to Hangar!'
}
}
}
}
post {
always {
archiveArtifacts artifacts: '**/build/libs/FancyHolograms-*.jar', allowEmptyArchive: true
}
success {
withCredentials([
string(credentialsId: 'DISC_WEBHOOK_URL', variable: 'DISC_WEBHOOK_URL')
]) {
discordSend description: "**Build:** ${env.BUILD_NUMBER} \n**Status:** ${currentBuild.currentResult} \n**Download:** https://modrinth.com/plugin/fancyholograms/versions",
footer: "Jenkins Pipeline", link: env.BUILD_URL, result: 'SUCCESS', title: "FancyHolograms #${env.BUILD_NUMBER}", webhookURL: "${DISC_WEBHOOK_URL}"
}
echo 'Build was successful!'
}
failure {
script {
withCredentials([
string(credentialsId: 'DISC_WEBHOOK_URL', variable: 'DISC_WEBHOOK_URL')
]) {
discordSend description: "**Build:** ${env.BUILD_NUMBER} \n**Status:** ${currentBuild.currentResult}", footer: "Jenkins Pipeline", link: env.BUILD_URL, result: 'FAILURE', title: "FancyHolograms #${env.BUILD_NUMBER}", "${DISC_WEBHOOK_URL}"
}
}
echo 'Build failed!'
}
}
}