以下是make de环境变量:
environment {
SERVICE_NAME = getServiceName()
}
这是方法:
def getServiceName() {
String projectName = env.JOB_BASE_NAME
print 'projectName '+projectName +'\n'
String[] projectParts = projectName.tokenize( '-' )
String bian = projectParts[1]
String name = projectParts[0]+'-'+projectParts[1]+'-'+projectParts[2]
return name
}
并且我需要在下一个bat命令中使用de SERVICE_NAME变量,但这给我一个错误:
bat '''
copy "C:\\Users\\""\\.jenkins\\workspace\\'"%env.SERVICE_NAME%"'\\target\\newman\\V2\\report.html" "C:\\server\\test\\'"env.SERVICE_NAME"'\\report_%date:~6,4%-%date:~3,2%-%date:~0,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%.html"
copy "C:\\Users\\""\\.jenkins\\workspace\\'"%env.SERVICE_NAME%"'\\target\\newman\\V2\\report.json" "C:\\server\\test\\'"env.SERVICE_NAME"'\\report_%date:~6,4%-%date:~3,2%-%date:~0,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%.json"
'''