使用参数

时间:2018-01-03 10:19:43

标签: batch-file jenkins

更新

当我使用set 之前 "双引号set "JAVA_OPTS=..."时,它会抛出

Error: Could not find or load main class Test

Jenkins代码

set "JAVA_OPTS=-Denvironment=%environment% -DloginUrl=%loginUrl% -Dusername=%username% -Dpassword=%password% -DuserCount=%userCount% -DprojectName=%projectName%"
"D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5\bin\gatling.bat" -s testFile

控制台输出

D:\Program Files\Jenkins\jobs\workspace>set "JAVA_OPTS=-Denvironment=https://test.com -DloginUrl=https://test1.com -Dusername=qauser -Dpassword=qauser -DuserCount=1 -DprojectName=Test" 
D:\Program Files\Jenkins\jobs\workspace>"D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5\bin\gatling.bat" -s testFile 
GATLING_HOME is set to "D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5"
JAVA = ""D:\Java\jdk1.8.0_25\bin\java.exe""
Error: Could not find or load main class Test
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

===== AND =====

当我在 set双引号" 之后使用"set JAVA_OPTS=..." 时,它会使用默认参数执行,这些参数在脚本中传递/不使用/覆盖选择参数

Jenkins代码

"set JAVA_OPTS=-Denvironment=%environment% -DloginUrl=%loginUrl% -Dusername=%username% -Dpassword=%password% -DuserCount=%userCount% -DprojectName=%projectName%"
"D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5\bin\gatling.bat" -s testFile

控制台输出

D:\Program Files\Jenkins\jobs\workspace>"set JAVA_OPTS=-Denvironment=https://test.com -DloginUrl=https://test1.com -Dusername=qauser -Dpassword=qauser -DuserCount=1 -DprojectName=Test"
The filename, directory name, or volume label syntax is incorrect.
D:\Program Files\Jenkins\jobs\workspace>"D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5\bin\gatling.bat" -s testFile 
GATLING_HOME is set to "D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5"
JAVA = ""D:\Java\jdk1.8.0_25\bin\java.exe""
12:00:22.246 [DEBUG] i.g.c.ZincCompiler$ - Inputs = {
12:00:22.249 [DEBUG] i.g.c.ZincCompiler$ - classpath = {
12:00:22.249 [DEBUG] i.g.c.ZincCompiler$ - D:\Program Files\Jenkins\GATLING2.2.5\gatling-charts-highcharts-bundle-2.2.5\lib\t-digest-3.1.jar
....
....
Finished: SUCCESS

enter image description here

0 个答案:

没有答案