Skip to content

Commit

Permalink
Add Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Aug 1, 2024
1 parent 03aefc8 commit 01d8561
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,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!'
}
}
}

0 comments on commit 01d8561

Please sign in to comment.