在groovy脚本中启动多浏览器url
在詹金斯管道中 我在groovy脚本中启动了多个URL,如下所示在groovy脚本中启动多浏览器url,groovy,jenkins-pipeline,Groovy,Jenkins Pipeline,在詹金斯管道中 我在groovy脚本中启动了多个URL,如下所示 stages { stage("Launch URL") { steps { script { def url1 = "https://www.paypal.com/us/home".toURL().getText() def url2 = "https://www.ebay.com".toURL().getText()
stages {
stage("Launch URL") {
steps {
script {
def url1 = "https://www.paypal.com/us/home".toURL().getText()
def url2 = "https://www.ebay.com".toURL().getText()
def url3 = "https://www.yahoo.com/".toURL().getText()
}
}
}
}
有没有更好的方法来做这个。
是否可以使用一个变量并执行所有三个URL?在代码的内部,您可以在groovy中执行以下操作:
def texts = ["https://www.paypal.com/us/home",
"https://www.ebay.com",
"https://www.yahoo.com/".collect {
it.toURL().text
}
其中文本将是一个
列表
,分别包含从每个url返回的字符串内容 你说的“更好的方式”是什么意思?由于Jenkins管道的执行方式,您还应该小心地使用getText()
和其他Groovy方法。我的意思是,不使用像url1、url2、url3这样的三个变量,而是使用一个变量并执行所有三个url。