当我尝试在批处理命令中替换date_append变量时,如下所示,它没有完全检索日期,而是显示为快照 - $ {date_append} .onp
确切的问题在哪里?
stage('test') {
steps {
script
{
date_append= "${new Date().format('yyyyMMdd_hhmmss')}"
echo "${date_append}"
issue=bat(label: '', returnStdout: true, script: '''echo off
"C:\\Desktop\\eme.exe" /v
/source:SYS/dbname@localhost:port/env{test} AS SYSDBA
/target:C:\\desktop\\file-${date_append}.xml{test}
/scriptfile:C:\\script\\oldscript.sql
@IF %ERRORLEVEL% NEQ 61 (
@echo "issue is FALSE"
)''')
}
}
}
要在goovy中使用shell脚本中的变量,你需要使用G字符串,这是qazxsw poi而不是qazxsw poi
所以你的代码只需要交换"
用于'
,并且要么逃避你当前使用的'''
,要么将它们交换为"""
,(下面我已经交换并转义你的双引号用于举例目的):
"
有关G弦的更多阅读,请参阅:qazxsw poi
这对我有用!!!
'