在powershell脚本中执行时获取错误无法从文件中读取数据" - 禁用unicode"

时间:2018-06-19 06:31:56

标签: node.js powershell npm

我创建了powershell脚本来执行此脚本中的newman apitest我通过post man man Json收集全局变量并从.csv文件传递数据。 但是当运行这个powershell时我会收到错误。

无法从文件中读取数据" - 禁用unicode" ENOENT没有这样的文件或目录,' C:\ npm \ node_modules \ newman \ bin - disable-unicode。

我的powershell脚本

#Windows Batch Command in Jenkins
#powershell.exe -executionpolicy bypass -command "& '%WORKSPACE%\jenkins_PostmanDemo.ps1'"

echo "You are in powershell script now ...."

$SourceFilePath = $env:WORKSPACE
$FilenamePostfix = "*.postman_collection.json"
$EnvironmentFile = "GlobalWizNG.postman_globals.json"

# Get all postman test files

$jsonFiles= Get-ChildItem -Path $SourceFilePath -name -Filter $FilenamePostfix | Sort-Object -Property CreationTime -Descending

#Change to directory  where we have NodeJS Installed. Otherwise the newman command will not be recognized
#You can install NPM and newman as a user and copy the  ~Roming\npm directory in the c:\ drive

#cd C:\Users\[UserName]\AppData\Roaming\npm\node_modules\newman\bin

cd C:\npm\node_modules\newman\bin

# loop through json files and execute newman to run the postman test

foreach($File in $jsonFiles){
$collectionfilepath="$SourceFilePath\$File"
$datafilepath=$collectionfilepath.Replace(".postman_collection.json",".csv")
$environmentfilepath="$SourceFilePath\$EnvironmentFile"
    node newman run --disable-unicode $collectionfilepath -e $environmentfilepath -d $datafilepath
}
exit $LASTEXITCODE

由于

0 个答案:

没有答案