Skip to content

Commit a3116af

Browse files
committed
[TRTLLM-7335][infra] use JobBuilder to trigger downstream job
Signed-off-by: Yiteng Niu <[email protected]>
1 parent 21409f3 commit a3116af

File tree

1 file changed

+30
-44
lines changed

1 file changed

+30
-44
lines changed

jenkins/L0_MergeRequest.groovy

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import groovy.transform.Field
55
import groovy.json.JsonOutput
66
import com.nvidia.bloom.KubernetesManager
77
import com.nvidia.bloom.Constants
8+
import com.nvidia.bloom.Logger
9+
import com.nvidia.bloom.JobBuilder
810
import org.jenkinsci.plugins.workflow.cps.CpsThread
911
import org.jsoup.Jsoup
1012
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils as jUtils
@@ -939,36 +941,7 @@ def getCommonParameters()
939941
]
940942
}
941943

942-
def triggerJob(jobName, parameters, jenkinsUrl = "", credentials = "")
943-
{
944-
if (jenkinsUrl == "" && env.localJobCredentials) {
945-
jenkinsUrl = env.JENKINS_URL
946-
credentials = env.localJobCredentials
947-
}
948-
def status = ""
949-
if (jenkinsUrl != "") {
950-
def jobPath = trtllm_utils.resolveFullJobName(jobName).replace('/', '/job/').substring(1)
951-
def handle = triggerRemoteJob(
952-
job: "${jenkinsUrl}${jobPath}/",
953-
auth: CredentialsAuth(credentials: credentials),
954-
parameters: trtllm_utils.toRemoteBuildParameters(parameters),
955-
pollInterval: 60,
956-
abortTriggeredJob: true,
957-
)
958-
status = handle.getBuildResult().toString()
959-
} else {
960-
def handle = build(
961-
job: jobName,
962-
parameters: trtllm_utils.toBuildParameters(parameters),
963-
propagate: false,
964-
)
965-
echo "Triggered job: ${handle.absoluteUrl}"
966-
status = handle.result
967-
}
968-
return status
969-
}
970-
971-
def launchJob(jobName, reuseBuild, enableFailFast, globalVars, platform="x86_64", additionalParameters = [:]) {
944+
def launchJob(pipeline, jobName, reuseBuild, enableFailFast, globalVars, platform="x86_64", additionalParameters = [:]) {
972945
def parameters = getCommonParameters()
973946
String globalVarsJson = writeJSON returnText: true, json: globalVars
974947
parameters += [
@@ -998,13 +971,26 @@ def launchJob(jobName, reuseBuild, enableFailFast, globalVars, platform="x86_64"
998971
parameters['reuseArtifactPath'] = "sw-tensorrt-generic/llm-artifacts/${JOB_NAME}/${reuseBuild}"
999972
}
1000973

974+
if (jobName.startsWith("/")) {
975+
jobName = jobName.substring(1)
976+
} else {
977+
def pos = env.JOB_NAME.lastIndexOf("/")
978+
if (pos != -1) {
979+
jobDir = env.JOB_NAME.substring(0, pos + 1)
980+
} else {
981+
jobDir = ""
982+
}
983+
jobName = "${jobDir}${jobName}"
984+
}
985+
1001986
echo "Trigger ${jobName} job, params: ${parameters}"
1002987

1003-
def status = triggerJob(jobName, parameters)
1004-
if (status != "SUCCESS") {
988+
def logger = new Logger(pipeline)
989+
def (jenkinsURL, buildStatus) = JobBuilder.build(pipeline, logger, jobName, parameters, 1, false)
990+
if (buildStatus != "SUCCESS") {
1005991
error "Downstream job did not succeed"
1006992
}
1007-
return status
993+
return buildStatus
1008994
}
1009995

1010996
def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
@@ -1023,9 +1009,9 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
10231009
'wheelDockerImagePy310': globalVars["LLM_ROCKYLINUX8_PY310_DOCKER_IMAGE"],
10241010
'wheelDockerImagePy312': globalVars["LLM_ROCKYLINUX8_PY312_DOCKER_IMAGE"],
10251011
]
1026-
launchJob("/LLM/helpers/Build-x86_64", reuseBuild, enableFailFast, globalVars, "x86_64", additionalParameters)
1012+
launchJob(pipeline, "/LLM/helpers/Build-x86_64", reuseBuild, enableFailFast, globalVars, "x86_64", additionalParameters)
10271013
}
1028-
def testStageName = "[Test-x86_64-Single-GPU] ${env.localJobCredentials ? "Remote Run" : "Run"}"
1014+
def testStageName = "[Test-x86_64-Single-GPU] Remote Run"
10291015
def singleGpuTestFailed = false
10301016
stage(testStageName) {
10311017
if (X86_TEST_CHOICE == STAGE_CHOICE_SKIP) {
@@ -1041,7 +1027,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
10411027
'wheelDockerImagePy312': globalVars["LLM_ROCKYLINUX8_PY312_DOCKER_IMAGE"],
10421028
]
10431029

1044-
launchJob("L0_Test-x86_64-Single-GPU", false, enableFailFast, globalVars, "x86_64", additionalParameters)
1030+
launchJob(pipeline, "L0_Test-x86_64-Single-GPU", false, enableFailFast, globalVars, "x86_64", additionalParameters)
10451031
} catch (InterruptedException e) {
10461032
throw e
10471033
} catch (Exception e) {
@@ -1082,7 +1068,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
10821068
}
10831069
}
10841070

1085-
testStageName = "[Test-x86_64-Multi-GPU] ${env.localJobCredentials ? "Remote Run" : "Run"}"
1071+
testStageName = "[Test-x86_64-Multi-GPU] Remote Run"
10861072
stage(testStageName) {
10871073
if (X86_TEST_CHOICE == STAGE_CHOICE_SKIP) {
10881074
echo "x86_64 test job is skipped due to Jenkins configuration"
@@ -1097,7 +1083,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
10971083
'wheelDockerImagePy312': globalVars["LLM_ROCKYLINUX8_PY312_DOCKER_IMAGE"],
10981084
]
10991085

1100-
launchJob("L0_Test-x86_64-Multi-GPU", false, enableFailFast, globalVars, "x86_64", additionalParameters)
1086+
launchJob(pipeline, "L0_Test-x86_64-Multi-GPU", false, enableFailFast, globalVars, "x86_64", additionalParameters)
11011087

11021088
} catch (InterruptedException e) {
11031089
throw e
@@ -1119,7 +1105,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
11191105
script {
11201106
def jenkinsUrl = ""
11211107
def credentials = ""
1122-
def testStageName = "[Test-SBSA-Single-GPU] ${env.localJobCredentials ? "Remote Run" : "Run"}"
1108+
def testStageName = "[Test-SBSA-Single-GPU] Remote Run"
11231109
def singleGpuTestFailed = false
11241110

11251111
if (testFilter[(ONLY_ONE_GROUP_CHANGED)] == "Docs") {
@@ -1131,7 +1117,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
11311117
def additionalParameters = [
11321118
"dockerImage": globalVars["LLM_SBSA_DOCKER_IMAGE"],
11331119
]
1134-
launchJob("/LLM/helpers/Build-SBSA", reuseBuild, enableFailFast, globalVars, "SBSA", additionalParameters)
1120+
launchJob(pipeline, "/LLM/helpers/Build-SBSA", reuseBuild, enableFailFast, globalVars, "SBSA", additionalParameters)
11351121
}
11361122
stage(testStageName) {
11371123
if (SBSA_TEST_CHOICE == STAGE_CHOICE_SKIP) {
@@ -1145,7 +1131,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
11451131
"dockerImage": globalVars["LLM_SBSA_DOCKER_IMAGE"],
11461132
]
11471133

1148-
launchJob("L0_Test-SBSA-Single-GPU", false, enableFailFast, globalVars, "SBSA", additionalParameters)
1134+
launchJob(pipeline, "L0_Test-SBSA-Single-GPU", false, enableFailFast, globalVars, "SBSA", additionalParameters)
11491135
} catch (InterruptedException e) {
11501136
throw e
11511137
} catch (Exception e) {
@@ -1186,7 +1172,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
11861172
}
11871173
}
11881174

1189-
testStageName = "[Test-SBSA-Multi-GPU] ${env.localJobCredentials ? "Remote Run" : "Run"}"
1175+
testStageName = "[Test-SBSA-Multi-GPU] Remote Run"
11901176
stage(testStageName) {
11911177
if (SBSA_TEST_CHOICE == STAGE_CHOICE_SKIP) {
11921178
echo "SBSA test job is skipped due to Jenkins configuration"
@@ -1199,7 +1185,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
11991185
"dockerImage": globalVars["LLM_SBSA_DOCKER_IMAGE"],
12001186
]
12011187

1202-
launchJob("L0_Test-SBSA-Multi-GPU", false, enableFailFast, globalVars, "SBSA", additionalParameters)
1188+
launchJob(pipeline, "L0_Test-SBSA-Multi-GPU", false, enableFailFast, globalVars, "SBSA", additionalParameters)
12031189

12041190
} catch (InterruptedException e) {
12051191
throw e
@@ -1234,7 +1220,7 @@ def launchStages(pipeline, reuseBuild, testFilter, enableFailFast, globalVars)
12341220
'runSanityCheck': env.JOB_NAME ==~ /.*PostMerge.*/ ? true : false,
12351221
]
12361222

1237-
launchJob("/LLM/helpers/BuildDockerImages", false, enableFailFast, globalVars, "x86_64", additionalParameters)
1223+
launchJob(pipeline, "/LLM/helpers/BuildDockerImages", false, enableFailFast, globalVars, "x86_64", additionalParameters)
12381224
}
12391225
}
12401226
}

0 commit comments

Comments
 (0)