@@ -9,39 +9,46 @@ isDebugging && set -x
99resolveVersion
1010: " ${MOHIST_BUILD:= lastSuccessfulBuild} "
1111
12- mohistBaseUrl=https://ci.codemc.io/job/MohistMC/
13- mohistJobs=${mohistBaseUrl} job/
14- mohistJob=${mohistJobs} Mohist-${VERSION} /
12+ mohistBaseUrl=" https://mohistmc.com/api/v2/projects/mohist/"
13+ mohistApiUrl=" ${mohistBaseUrl}${VERSION} /builds/"
1514
1615function logMohistAvailableVerisons(){
1716 logError " check ${mohistBaseUrl} for available versions"
1817 logError " and set VERSION accordingly"
1918}
2019
21- if ! get --exists " ${mohistJob } " ; then
20+ if ! get --exists " ${mohistApiUrl } " ; then
2221 logError " Mohist builds do not exist for ${VERSION} "
2322 logMohistAvailableVerisons
2423 exit 1
2524fi
2625
27- buildRelPath=$(
28- get --json-path ' $.artifacts[0].relativePath' " ${mohistJob}${MOHIST_BUILD} /api/json"
26+ if [[ " ${MOHIST_BUILD} " == " lastSuccessfulBuild" ]]; then
27+ # Get the latest build number from the API
28+ buildNumber=$(
29+ get --json-path ' $.builds[-1].number' " ${mohistApiUrl} "
30+ )
31+ MOHIST_BUILD=" ${buildNumber} "
32+ fi
33+
34+ downloadUrl=$(
35+ get --json-path " $.builds[?(@.number==${MOHIST_BUILD} )].url" " ${mohistApiUrl} "
2936)
3037
31- baseName=$( basename " ${buildRelPath} " )
32- if [[ ${baseName} != * -server.jar* ]]; then
33- logError " Mohist build for ${VERSION} is not a valid server jar, found ${baseName} "
38+ if [[ -z " ${downloadUrl} " ]]; then
39+ logError " Could not find build ${MOHIST_BUILD} for version ${VERSION} "
3440 logMohistAvailableVerisons
3541 exit 1
3642fi
3743
38- export SERVER=" /data/${baseName} "
44+ SERVER=" /data/mohist- ${VERSION} - ${MOHIST_BUILD} -server.jar "
3945
4046if [ ! -f " ${SERVER} " ]; then
41- log " Downloading ${baseName }"
42- get -o " ${SERVER} " " ${mohistJob}${MOHIST_BUILD} /artifact/ ${buildRelPath }"
47+ log " Downloading Mohist build ${MOHIST_BUILD} for ${VERSION }"
48+ get -o " ${SERVER} " " ${downloadUrl } "
4349fi
4450
4551export FAMILY=HYBRID
52+ export SERVER
4653
4754exec " ${SCRIPTS:-/ } start-spiget" " $@ "
0 commit comments