diff --git a/back/services/cron.ts b/back/services/cron.ts index 48d7f680..5897fac1 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -401,7 +401,7 @@ export default class CronService { } } - private getKey(command: string) { + private getKey(command: string): string { const start = command.lastIndexOf('/') !== -1 ? command.lastIndexOf('/') + 1 : 0; const end = @@ -409,10 +409,15 @@ export default class CronService { ? command.lastIndexOf('.') : command.length; - const tmpStr = command.startsWith('/') ? command.substring(1) : command; - const index = tmpStr.indexOf('/') !== -1 ? tmpStr.indexOf('/') : 0; + const tmpStr = command.substring(0, start - 1); + let index = 0; + if (tmpStr.lastIndexOf('/') !== -1 && tmpStr.startsWith('http')) { + index = tmpStr.lastIndexOf('/'); + } else if (tmpStr.lastIndexOf(':') !== -1 && tmpStr.startsWith('git@')) { + index = tmpStr.lastIndexOf(':'); + } if (index) { - return `${tmpStr.substring(0, index)}_${command.substring(start, end)}`; + return `${tmpStr.substring(index + 1)}_${command.substring(start, end)}`; } else { return command.substring(start, end); } diff --git a/shell/task.sh b/shell/task.sh index dd2382f0..9946a4e0 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -93,7 +93,7 @@ run_normal() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}" @@ -162,7 +162,7 @@ run_concurrent() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}" @@ -231,7 +231,7 @@ run_designated() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}" @@ -294,7 +294,7 @@ run_else() { log_dir_tmp_path="${file_param}" fi fi - log_dir_tmp_path="${log_dir_tmp_path%%/*}" + log_dir_tmp_path="${log_dir_tmp_path%/*}" log_dir_tmp_path="${log_dir_tmp_path##*/}" [[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}" log_dir="${log_dir_tmp%.*}"