Skip to content

Commit

Permalink
bug: 修复重试和任务认领失败的逻辑问题 #6646
Browse files Browse the repository at this point in the history
  • Loading branch information
yongyiduan committed May 7, 2022
1 parent c304791 commit ea5e471
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ interface EngineBuildSDKApi : WorkerRestApiSDK {

fun getJobContext(): Map<String, String>

fun getBuildDetailUrl(): String
fun getBuildDetailUrl(): Result<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ open class EngineBuildResourceApi : AbstractBuildResourceApi(), EngineBuildSDKAp
return emptyMap()
}

override fun getBuildDetailUrl(): String {
override fun getBuildDetailUrl(): Result<String> {
val path = getRequestUrl(path = "api/build/worker/detail_url")
val request = buildGet(path)
val errorMessage = "构建超时结束请求失败"
Expand All @@ -161,7 +161,7 @@ open class EngineBuildResourceApi : AbstractBuildResourceApi(), EngineBuildSDKAp
writeTimeoutInSec = 30L
)
} catch (ignore: Throwable) {
return ""
return Result("")
}
return objectMapper.readValue(responseContent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object EngineService {
// #5277 将Job上下文传入本次agent任务
val jobContext = buildApi.getJobContext().toMutableMap()
jobContext[JOB_OS_CONTEXT] = AgentEnv.getOS().name
jobContext[CI_BUILD_URL] = buildApi.getBuildDetailUrl()
jobContext[CI_BUILD_URL] = buildApi.getBuildDetailUrl().data ?: ""
return ret.copy(variables = ret.variables.plus(jobContext))
}

Expand Down

0 comments on commit ea5e471

Please sign in to comment.