我试图将参数从Jenkins传递到gradle.properties文件中,以用于Powershell脚本。但是,我无法从Jenkins获取任何参数以进入gradle.properties文件。我什至创建了gradle.properties文件并指定了参数,而powershell脚本无法使用它。
这是我的Powershell:
$ExeFile = $args[0]
write-host $ExeFile
cd 'C:\Program Files (x86)\Jenkins\workspace\AppInstall'
"starting install at $(Get-Date -format 'U')"
($ConsoleCommand = Get-Content -Path .\input.txt -Raw)
# Results - showing the commands in the file before process them
write-host "before foreach loop"
whoami
ForEach($CmdLine in $ConsoleCommand)
{ Start-Process -FilePath $ExeFile -ArgumentList "-NoExit","-Command &{ $CmdLine }" }
这是我的gradle.properties文件:
# Enable Gradle daemon for all builds.
org.gradle.daemon=true
ExeFile=$ExeFile
这是我的gradle.build文件:
ext.systemProperties= System.properties
String inputFromJenkins = System.getenv('ExeFile')
println('ExeFile = ' + inputFromJenkins)
task execPs(type:Exec) {
commandLine 'cmd', '/c', 'Powershell -File appInstall.ps1 '
}
这是詹金斯的设置:
感谢您的帮助,谢谢