jenkins_master.groovy 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * BepInEx Bleeding Edge build CI jenkinsfile
  3. */
  4. lastBuildCommit = ""
  5. pipeline {
  6. agent any
  7. parameters {
  8. // Check if the build is Bleeding Edge. Affects whether the result is pushed to BepisBuilds
  9. booleanParam(name: "IS_BE")
  10. }
  11. stages {
  12. stage('Pull Projects') {
  13. steps {
  14. script {
  15. if(fileExists('last_build_commit'))
  16. lastBuildCommit = readFile 'last_build_commit'
  17. }
  18. // Clean up old project before starting
  19. cleanWs()
  20. dir('BepInEx') {
  21. git 'https://github.com/BepInEx/BepInEx.git'
  22. script {
  23. longCommit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
  24. }
  25. }
  26. }
  27. }
  28. stage('Build BepInEx') {
  29. steps {
  30. dir('BepInEx') {
  31. sh "chmod u+x build.sh"
  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. }