我有一个以下的cURL命令来在Jenkins中执行soapui测试。在那里,我传递了两个参数variable1和variable2。
curl --form "project=/build.tool/.jenkins/jobs/$variable1" --form "suite=$variable2" host
我有一个以下.txt文件,其中这些变量的值位于由空格分隔的两列中。如何在cURL命令中循环显示所有这些值?
#file1.txt
project1.xml TestSuite_1
project1.xml TestSuite_2
project2.xml TestSuite_3
project2.xml TestSuite_4
project3.xml TestSuite_5
答案 0 :(得分:1)
在测试输入中使用它
while read p; do
var1=`echo $p | awk '{print $1" "}'`
var2=`echo $p | awk '{ print " "$2}'`
echo $var1
echo $var2
done <infile
infile包含您的数据。
输出:
project1.xml
TestSuite_1
project1.xml
TestSuite_2
project2.xml
TestSuite_3
project2.xml
TestSuite_4
project3.xml
TestSuite_5
现在你已将它们存储在变量中,你可以将它们添加到curl
命令
curl --form "project=/build.tool/.jenkins/jobs/$var1" --form "suite=$var2" host