【发布时间】:2018-08-03 11:21:38
【问题描述】:
我必须在 sidecar 模式下运行两个 docker 容器。我花了几天时间尝试实现正确的管道,但现在我很绝望,因为我的想法都没有真正奏效。
首先,我已经阅读了这个区块Running sidecar containers
它在 node {} 块内实现方法。这是我的管道现在的样子:
pipeline {
agent any
options {
disableConcurrentBuilds()
}
stages {
stage("Obtain images") {
steps {
script {
writeFile(file: './ui-tests/env.yaml', text: "environment:\n # dev or stage\n type: dev\n lang: en\n")
withDockerRegistry([credentialsId: 'my-hub', url: 'https://myhub.hub']) {
def selena = docker.image('myhub.hub/selenium-dev:latest')
def uirun = docker.image('myhub.hub/ui-shell-runner:latest')
selena.pull()
uirun.pull()
}
}
}
}
stage("Run tests") {
steps {
node('pyrunner') {
docker.image('myhub.hub/selenium-dev').withRun('-e JAVA_OPTS=-Xmx1024m') { test ->
docker.image('myhub.hub/selenium-dev').inside("--link ${test.id}:se") {
sh 'pwd'
}
docker.image('myhub.hub/ui-shell-runner:latest').inside("--link ${test.id}:se") {
sh 'cd ui-tests ; pwd ; nose2 -v --attribute desktop-site,type=smoke'
}
}
}
}
}
}
}
这就是想法。第一个带有 selenium myhub.hub/selenium-dev 的容器 - 在后台运行,第二个容器 myhub.hub/ui-shell-runner 包含使用第一个容器的 nose2 实用程序。我尝试实现 node,尝试完全删除它并将我的代码移动到 steps,我尝试删除所有内容并通过 sh 'docker container run 运行我的容器...' (虽然这不好)。我的想法都没有像我预期的那样真正起作用。并列出了与
一起崩溃的管道 WorkflowScript: 28: Expected a symbol @ line 28, column 6.
docker.image('myhub.hub/selenium-dev').withRun('-e JAVA_OPTS=-Xmx1024m') { test ->
WorkflowScript: 28: Arguments to "error" must be explicitly named. @ line 28, column 6.
docker.image('myhub.hub/selenium-dev').withRun('-e JAVA_OPTS=-Xmx1024m') { test ->
我没有想法。我接下来要做什么?
【问题讨论】:
标签: python selenium docker jenkins jenkins-pipeline