Skip to content

Commit 1e28390

Browse files
authored
update mohist download script to use new API endpoint (#3247)
1 parent f79ef8f commit 1e28390

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

scripts/start-deployMohist

+19-12
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,46 @@ isDebugging && set -x
99
resolveVersion
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

1615
function 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
2524
fi
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
3642
fi
3743

38-
export SERVER="/data/${baseName}"
44+
SERVER="/data/mohist-${VERSION}-${MOHIST_BUILD}-server.jar"
3945

4046
if [ ! -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}"
4349
fi
4450

4551
export FAMILY=HYBRID
52+
export SERVER
4653

4754
exec "${SCRIPTS:-/}start-spiget" "$@"

0 commit comments

Comments
 (0)