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,17 +13,19 @@ pipeline {
branch "master"
}
steps {
withCredentials([usernamePassword(credentialsId: '85b7099f-2e65-461e-b2ce-124edec41ed6', passwordVariable: 'plexPassword', usernameVariable: 'plexUser')]) {
withGradle {
sh "./gradlew publish --no-daemon"
}
}
}
}
}
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()
}
}

View File

@ -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.");

View File

@ -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