Skip to content

Commit

Permalink
Update JenkinsNumber.groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Mar 29, 2024
1 parent ca6293c commit 9f2aa60
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions buildSrc/src/main/groovy/com/mohistmc/tasks/JenkinsNumber.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@ import groovy.json.JsonSlurper
class JenkinsNumber {

static String info() {
Locale locale = Locale.getDefault()
if (locale.getCountry() == "CN") {
try {
def data = new JsonSlurper().parseText(new URL("https://ci.codemc.io/job/MohistMC/job/Mohist-1.16.5/api/json").getText("UTF-8"))
return data.builds["number"][0]
} catch (Exception ignored) {
return 'dev'
} else {
try {
def conn = new URL("https://ci.codemc.io/job/MohistMC/job/Mohist-1.16.5/api/json").openConnection()
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0")
conn.connect()
def root = conn.content.text
def jsonSluper = new JsonSlurper()

String data = jsonSluper.parseText(root)
def number = data.substring(data.indexOf("number")).split(",")
return Integer.valueOf(number[0].replace("number=", "")).intValue()
} catch (Exception e1) {
return 'dev'
}
}
}
}

0 comments on commit 9f2aa60

Please sign in to comment.