我的结构如下:
我想获得什么?Machine 1从Jenkins接收一些参数(用于JMeter测试)。
path/Performance.bat %param1% %param2% %param3%因此,Performance.bat看起来类似于:
IF %param1%==param1_value(
IF %param2%==param2_value(
@echo
path_to_psexec\PsExec.exe \\machine1_address -u user -p password cmd /c (
MKDIR %param3%\Automation_Results_Build_%BUILD_NUMBER%_ID
cd %JMeterPath%/
jmeter -n -t [...])
exit /b 0
))因此,基本上它创建一个结果文件夹,然后导航到JMeter位置,并尝试使用给定的值运行性能测试。
问题来了。PSExec似乎没有按预期执行命令。通过CMD发送了3个命令:创建结果文件夹,导航到JMeter路径,运行测试。我的方法有什么问题?如何在同一个PSexec调用中运行多个CMD命令?
输出:
ECHO is on.
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Connecting to machine_address...
Starting PSEXESVC service on machine_address...
Connecting with PsExec service on machine_address...
Starting cmd on machine_address...
cmd exited on machine_address with error code 0.
The system cannot find the path specified.
'jmeter' is not recognized as an internal or external command,
operable program or batch file.为什么The system cannot find the path specified.
我不想在机器2上创建.bat文件,因为我想在Jenkins中看到测试的输出。
发布于 2018-10-26 09:40:17
您可以创建一个PowerShell脚本,在其中可以执行所有命令。
下面的命令需要包含在您的PowerShell脚本中,它将连接到远程计算机并在远程机器上执行命令。
$machine_addr = "your_ip_address"
$user = your_username
$Password = your_password
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $user ,$pass
Invoke-Command -ComputerName $machine_addr -ScriptBlock {C:\path_to_your_jmeter_with_parameters} -Credential $Cred您可以根据您的方便添加其他命令,例如要创建文件夹。
New-Item -Path "folder name with path" -ItemType directory 创建PowerShell脚本后,只需从批处理文件中调用即可。
C:\Users\%username%\Desktop\path_to_your_powershell_file\filename.ps1建议:您也可以创建带有参数的单个PowerShell脚本,就像您对批处理文件所做的一样。(这只会减轻创建批处理文件的负担)
https://stackoverflow.com/questions/53002550
复制相似问题