-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03aefc8
commit 01d8561
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!' | ||
} | ||
} | ||
} |