问题描述
我想在后台运行我的命令,我正在詹金斯管道中尝试这个这是我的命令
I want to run my command in background.And I am trying this in jenkins pipelineThis is my command
sh"./node_modules/.bin/selenium-standalone start \&"
sh "./node_modules/.bin/selenium-standalone start \&"
但是当我运行此命令时&由于命令失败而得到单引号.输出:./node_modules/.bin/selenium-standalone start'&'
But when I run this command & gets single quote because of which the command fails.OUTPUT : ./node_modules/.bin/selenium-standalone start '&'
谁能建议我该如何逃避&时髦,所以我得到了&没有单引号.
Can anyone suggest how I should escape the & in groovy so I just get & without single quote.
推荐答案
这并不容易,首先是因为&
是交互式外壳程序中用于作业控制的命令,也是因为进程树在其中的工作方式Linux.
This won't work that easily, first because &
is a command for job control in the interactive shell, and also because of how process trees work in Linux.
长话短说,如果需要在后台启动命令,则应使用 daemonize :
To make a long story short, if you need to start a command in background, you should use daemonize:
sh label: "starting selenium in the background",
script: "/usr/local/bin/daemonize ./node_modules/.bin/selenium-standalone start"
这篇关于逃避groovy中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!