简体   繁体   中英

string concatenation with variables in Jenkins bat command

I have a simple Jenkins function / procedure:

def StartContainer() {
    def SqlPort = BranchToPort[env.BRANCH_NAME]
    bat "docker run -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD=P@ssword1\" --name SQLLinux${env.BRANCH_NAME} -d -i -p $SqlPort:1433 microsoft/mssql-server-linux"
}

BranchToPort does exactly what I want it to do, the problem I have is plugging the value it returns into the following call to bat, I've tried all sorts of things and this either results in language compile errors with the groovy script or the bat command ending immediately after the -p command. There is obviously something really simple I'm missing here.

我的问题在于确定Groovy映射的范围超出了旋转容器的方法的范围,如果我将映射的声明移入与启动容器的方法相同的方法,它将起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM