diff --git a/Jenkinsfile b/Jenkinsfile index 51b20c6..f66eeb0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,8 +13,10 @@ pipeline { branch "master" } steps { + withCredentials([usernamePassword(credentialsId: '85b7099f-2e65-461e-b2ce-124edec41ed6', passwordVariable: 'plexPassword', usernameVariable: 'plexUser')]) { withGradle { sh "./gradlew publish --no-daemon" + } } } } @@ -22,8 +24,8 @@ pipeline { post { always { archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true - javadoc javadocDir: 'build/docs/javadoc', keepAll: false - discordSend description: "Jenkins", link: env.BUILD_URL, result: currentBuild.currentResult, title: JOB_NAME, webhookURL: env.PLEX_WEBHOOK_URL + javadoc javadocDir: "build/docs/javadoc", keepAll: false + discordSend description: "**Build:** ${env.BUILD_NUMBER}\n**Status:** ${currentBuild.currentResult}", enableArtifactsList: true, footer: "Built with Jenkins", link: env.BUILD_URL, result: currentBuild.currentResult, scmWebUrl: "https://github.com/plexusorg/Plex", showChangeset: true, title: env.JOB_NAME, webhookURL: env.PLEX_WEBHOOK_URL cleanWs() } } diff --git a/src/main/java/dev/plex/util/UpdateChecker.java b/src/main/java/dev/plex/util/UpdateChecker.java index a6f1bb0..8bca755 100644 --- a/src/main/java/dev/plex/util/UpdateChecker.java +++ b/src/main/java/dev/plex/util/UpdateChecker.java @@ -40,6 +40,7 @@ public class UpdateChecker extends PlexBase * > 0 = Number of commits behind */ private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/Plex/"; + private String branch = plugin.config.getString("update_branch"); private int distance = -4; // Adapted from Paper @@ -83,10 +84,15 @@ public class UpdateChecker extends PlexBase public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, boolean verbose) { + if (branch == null) + { + PlexLog.error("You did not specify a branch to use for update checking. Defaulting to master."); + branch = "master"; + } // If it's -4, it hasn't checked for updates yet if (distance == -4) { - distance = fetchDistanceFromGitHub("plexusorg/Plex", "master", Plex.build.head); + distance = fetchDistanceFromGitHub("plexusorg/Plex", branch, Plex.build.head); PlexLog.debug("Never checked for updates, checking now..."); } else @@ -94,7 +100,7 @@ public class UpdateChecker extends PlexBase // If the request isn't asked to be cached, fetch it if (!cached) { - distance = fetchDistanceFromGitHub("plexusorg/Plex", "master", Plex.build.head); + distance = fetchDistanceFromGitHub("plexusorg/Plex", branch, Plex.build.head); PlexLog.debug("We have checked for updates before, but this request was not asked to be cached."); } else @@ -143,7 +149,7 @@ public class UpdateChecker extends PlexBase public void updateJar(CommandSender sender) { CloseableHttpClient client = HttpClients.createDefault(); - HttpGet get = new HttpGet(DOWNLOAD_PAGE + "job/master/lastSuccessfulBuild/api/json"); + HttpGet get = new HttpGet(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/api/json"); try { HttpResponse response = client.execute(get); @@ -156,7 +162,7 @@ public class UpdateChecker extends PlexBase try { FileUtils.copyURLToFile( - new URL(DOWNLOAD_PAGE + "job/master/lastSuccessfulBuild/artifact/build/libs/" + name), + new URL(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/artifact/build/libs/" + name), new File(Bukkit.getUpdateFolderFile(), name) ); sendMini(sender, "Saved new jar. Please restart your server."); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 49f88e2..9e0bbf8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -208,5 +208,8 @@ worlds: stone: 16 bedrock: 1 +# What branch should Plex fetch updates from? +update_branch: master + # Additional logging for debugging debug: false \ No newline at end of file