jenkins_master.groovy 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * BepInEx Bleeding Edge build CI jenkinsfile
  3. */
  4. pipeline {
  5. agent any
  6. parameters {
  7. // Check if the build is Bleeding Edge. Affects whether the result is pushed to BepisBuilds
  8. booleanParam(name: "IS_BE")
  9. }
  10. stages {
  11. stage('Pull Projects') {
  12. steps {
  13. script {
  14. if(fileExists('last_build_commit'))
  15. lastBuildCommit = readFile 'last_build_commit'
  16. else
  17. lastBuildCommit = ""
  18. }
  19. // Clean up old project before starting
  20. cleanWs()
  21. dir('BepInEx') {
  22. git 'https://github.com/BepInEx/BepInEx.git'
  23. script {
  24. longCommit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
  25. }
  26. }
  27. }
  28. }
  29. stage('Build BepInEx') {
  30. steps {
  31. dir('BepInEx') {
  32. sh "./build.sh --target=Pack --bleeding_edge=${params.IS_BE} --build_id=${currentBuild.id} --last_build_commit=${lastBuildCommit}"
  33. }
  34. }
  35. }
  36. stage('Package') {
  37. steps {
  38. dir('BepInEx/bin/dist') {
  39. archiveArtifacts "*.zip"
  40. }
  41. }
  42. }
  43. }
  44. post {
  45. cleanup {
  46. script {
  47. writeFile file: 'last_build_commit', text: lastBuildCommit
  48. }
  49. }
  50. success {
  51. script {
  52. lastBuildCommit = longCommit
  53. if(params.IS_BE) {
  54. dir('BepInEx/bin/dist') {
  55. def filesToSend = findFiles(glob: '*.*').collect {it.name}
  56. withCredentials([string(credentialsId: 'bepisbuilds_addr', variable: 'BEPISBUILDS_ADDR')]) {
  57. sh """curl --upload-file "{${filesToSend.join(',')}}" --ftp-pasv --ftp-skip-pasv-ip --ftp-create-dirs --ftp-method singlecwd --disable-epsv ftp://${BEPISBUILDS_ADDR}/bepinex_be/artifacts/${env.BUILD_NUMBER}/"""
  58. }
  59. }
  60. }
  61. }
  62. //Notify Bepin Discord of successfull build
  63. withCredentials([string(credentialsId: 'discord-notify-webhook', variable: 'DISCORD_WEBHOOK')]) {
  64. discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n\n[**Artifacts on BepisBuilds**](https://builds.bepis.io/projects/bepinex_be)", footer: 'Jenkins via Discord Notifier', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK
  65. }
  66. }
  67. failure {
  68. //Notify Discord of failed build
  69. withCredentials([string(credentialsId: 'discord-notify-webhook', variable: 'DISCORD_WEBHOOK')]) {
  70. discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})", footer: 'Jenkins via Discord Notifier', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK
  71. }
  72. }
  73. }
  74. }