@@ -12,10 +12,9 @@ import com.tencent.bk.devops.atom.task.utils.JobUtils
1212import com.tencent.bk.devops.atom.task.utils.Keys
1313import com.tencent.bk.devops.atom.utils.json.JsonUtil
1414import org.apache.commons.lang3.StringUtils
15- import java.nio.charset.Charset
16- import java.util.Base64
1715import org.slf4j.LoggerFactory
18- import java.lang.IndexOutOfBoundsException
16+ import java.nio.charset.Charset
17+ import java.util.*
1918
2019@AtomService(paramClass = InnerJobParam ::class )
2120class JobScriptAtom : TaskAtom <InnerJobParam > {
@@ -54,6 +53,13 @@ class JobScriptAtom : TaskAtom<InnerJobParam> {
5453 fastExecuteScript(param, result)
5554 }
5655
56+ private fun printLink (bizId : String , taskInstanceId : Long , jobHost : String ) {
57+ logger.info(" 对接蓝鲸企业版3.x/社区版6.x中的作业平台请点击以下链接查看详情:" )
58+ logger.info(JobUtils .getV3DetailUrl(bizId, taskInstanceId, jobHost))
59+ logger.info(" 对接蓝鲸企业版2.x/社区版5.x中的作业平台请点击以下链接查看详情:" )
60+ logger.info(JobUtils .getV2DetailUrl(bizId, taskInstanceId, jobHost))
61+ }
62+
5763 private fun fastExecuteScript (
5864 param : InnerJobParam ,
5965 result : AtomResult
@@ -63,6 +69,11 @@ class JobScriptAtom : TaskAtom<InnerJobParam> {
6369 val taskId = param.pipelineTaskId
6470 val targetAccount = param.account
6571 val timeout = 0L + (param.timeout ? : 1000 )
72+ if (timeout < 60L || timeout > 72000 ) {
73+ result.status = Status .failure
74+ result.message = " timeout参数不合法,必须为60-72000之间的整数"
75+ return
76+ }
6677 var operator = param.pipelineStartUserName
6778 var scriptContent = when (param.scriptType) {
6879 " 1" -> {
@@ -139,7 +150,7 @@ class JobScriptAtom : TaskAtom<InnerJobParam> {
139150
140151 try {
141152 val taskInstanceId = JobUtils .fastExecuteScript(fastExecuteScriptReq, this .esbApiHost)
142- logger.info( JobUtils .getDetailUrl( bizId, taskInstanceId, jobHost) )
153+ printLink( bizId, taskInstanceId, jobHost)
143154 val startTime = System .currentTimeMillis()
144155 checkStatus(
145156 bizId = bizId,
@@ -148,11 +159,9 @@ class JobScriptAtom : TaskAtom<InnerJobParam> {
148159 taskInstanceId = taskInstanceId,
149160 operator = operator ,
150161 buildId = buildId,
151- jobHost = esbApiHost,
152162 result = result
153163 )
154-
155- logger.info(JobUtils .getDetailUrl(bizId, taskInstanceId, jobHost))
164+ printLink(bizId, taskInstanceId, jobHost)
156165 } catch (e: Exception ) {
157166 logger.error(" Job API invoke failed" , e)
158167 result.status = Status .failure
@@ -175,16 +184,15 @@ class JobScriptAtom : TaskAtom<InnerJobParam> {
175184 operator : String ,
176185 buildId : String ,
177186 taskId : String ,
178- jobHost : String ,
179187 result : AtomResult
180188 ) {
181189
182190 var needContinue = true
183191
184192 while (needContinue) {
185193 Thread .sleep(2000 )
186- val taskResult = JobUtils .getTaskResult(appId, appSecret, bizId, taskInstanceId, operator , jobHost )
187- logger.info( JobUtils .getDetailUrl( bizId, taskInstanceId, jobHost) )
194+ val taskResult = JobUtils .getTaskResult(appId, appSecret, bizId, taskInstanceId, operator , esbApiHost )
195+ printLink( bizId, taskInstanceId, jobHost)
188196 if (taskResult.isFinish) {
189197 needContinue = false
190198 if (taskResult.success) {
0 commit comments