This commit is contained in:
9378062 2022-04-07 19:09:25 -04:00
commit 6f7fcc5b51
3 changed files with 17 additions and 6 deletions

6
Jenkinsfile vendored
View File

@ -13,8 +13,10 @@ pipeline {
branch "master" branch "master"
} }
steps { steps {
withCredentials([usernamePassword(credentialsId: '85b7099f-2e65-461e-b2ce-124edec41ed6', passwordVariable: 'plexPassword', usernameVariable: 'plexUser')]) {
withGradle { withGradle {
sh "./gradlew publish --no-daemon" sh "./gradlew publish --no-daemon"
}
} }
} }
} }
@ -22,8 +24,8 @@ pipeline {
post { post {
always { always {
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
javadoc javadocDir: 'build/docs/javadoc', keepAll: false 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 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() cleanWs()
} }
} }

View File

@ -40,6 +40,7 @@ public class UpdateChecker extends PlexBase
* > 0 = Number of commits behind * > 0 = Number of commits behind
*/ */
private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/Plex/"; private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/Plex/";
private String branch = plugin.config.getString("update_branch");
private int distance = -4; private int distance = -4;
// Adapted from Paper // Adapted from Paper
@ -83,10 +84,15 @@ public class UpdateChecker extends PlexBase
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, boolean verbose) 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 it's -4, it hasn't checked for updates yet
if (distance == -4) 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..."); PlexLog.debug("Never checked for updates, checking now...");
} }
else else
@ -94,7 +100,7 @@ public class UpdateChecker extends PlexBase
// If the request isn't asked to be cached, fetch it // If the request isn't asked to be cached, fetch it
if (!cached) 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."); PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
} }
else else
@ -143,7 +149,7 @@ public class UpdateChecker extends PlexBase
public void updateJar(CommandSender sender) public void updateJar(CommandSender sender)
{ {
CloseableHttpClient client = HttpClients.createDefault(); 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 try
{ {
HttpResponse response = client.execute(get); HttpResponse response = client.execute(get);
@ -156,7 +162,7 @@ public class UpdateChecker extends PlexBase
try try
{ {
FileUtils.copyURLToFile( 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) new File(Bukkit.getUpdateFolderFile(), name)
); );
sendMini(sender, "Saved new jar. Please restart your server."); sendMini(sender, "Saved new jar. Please restart your server.");

View File

@ -208,5 +208,8 @@ worlds:
stone: 16 stone: 16
bedrock: 1 bedrock: 1
# What branch should Plex fetch updates from?
update_branch: master
# Additional logging for debugging # Additional logging for debugging
debug: false debug: false