Jenkins Docker Sidecar with Container Running a daemon command
I want to run ZAP as a proxy in my pipeline, and run my selenium tests through the proxy. Im just using curl in a container in place of selenium for my testing and was able to make this work locally using docker.
In my pipeline, zap starts up, but the pipeline just sits in the zap container after that, never progressing to the second container. I understand why, Ive launched a process as a daemon, its never going to finish, so the step never finished. I just dont understand how to accomplish what I need in jenkins.
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090') { c ->
docker.image('owasp/zap2docker-weekly').inside("-v $WORKSPACE:/zap/wrk:rw") {
/* Wait until mysql service is up */
sh """
zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
"""
}
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
I essentially need to start zap with the command im using in the 'inside', and only kill the container when the second containers stages are complete.
docker jenkins zap
add a comment |
I want to run ZAP as a proxy in my pipeline, and run my selenium tests through the proxy. Im just using curl in a container in place of selenium for my testing and was able to make this work locally using docker.
In my pipeline, zap starts up, but the pipeline just sits in the zap container after that, never progressing to the second container. I understand why, Ive launched a process as a daemon, its never going to finish, so the step never finished. I just dont understand how to accomplish what I need in jenkins.
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090') { c ->
docker.image('owasp/zap2docker-weekly').inside("-v $WORKSPACE:/zap/wrk:rw") {
/* Wait until mysql service is up */
sh """
zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
"""
}
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
I essentially need to start zap with the command im using in the 'inside', and only kill the container when the second containers stages are complete.
docker jenkins zap
add a comment |
I want to run ZAP as a proxy in my pipeline, and run my selenium tests through the proxy. Im just using curl in a container in place of selenium for my testing and was able to make this work locally using docker.
In my pipeline, zap starts up, but the pipeline just sits in the zap container after that, never progressing to the second container. I understand why, Ive launched a process as a daemon, its never going to finish, so the step never finished. I just dont understand how to accomplish what I need in jenkins.
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090') { c ->
docker.image('owasp/zap2docker-weekly').inside("-v $WORKSPACE:/zap/wrk:rw") {
/* Wait until mysql service is up */
sh """
zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
"""
}
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
I essentially need to start zap with the command im using in the 'inside', and only kill the container when the second containers stages are complete.
docker jenkins zap
I want to run ZAP as a proxy in my pipeline, and run my selenium tests through the proxy. Im just using curl in a container in place of selenium for my testing and was able to make this work locally using docker.
In my pipeline, zap starts up, but the pipeline just sits in the zap container after that, never progressing to the second container. I understand why, Ive launched a process as a daemon, its never going to finish, so the step never finished. I just dont understand how to accomplish what I need in jenkins.
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090') { c ->
docker.image('owasp/zap2docker-weekly').inside("-v $WORKSPACE:/zap/wrk:rw") {
/* Wait until mysql service is up */
sh """
zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
"""
}
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
I essentially need to start zap with the command im using in the 'inside', and only kill the container when the second containers stages are complete.
docker jenkins zap
docker jenkins zap
asked Nov 20 '18 at 13:53
Justin SeiserJustin Seiser
245
245
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You could directly pass the zap command in the withRun
part:
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090 -v $WORKSPACE:/zap/wrk:rw', 'zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true') { c ->
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
withRun
allows you to overwrite the CMD of the zap-container. Check this API-documentation.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394538%2fjenkins-docker-sidecar-with-container-running-a-daemon-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could directly pass the zap command in the withRun
part:
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090 -v $WORKSPACE:/zap/wrk:rw', 'zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true') { c ->
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
withRun
allows you to overwrite the CMD of the zap-container. Check this API-documentation.
add a comment |
You could directly pass the zap command in the withRun
part:
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090 -v $WORKSPACE:/zap/wrk:rw', 'zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true') { c ->
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
withRun
allows you to overwrite the CMD of the zap-container. Check this API-documentation.
add a comment |
You could directly pass the zap command in the withRun
part:
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090 -v $WORKSPACE:/zap/wrk:rw', 'zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true') { c ->
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
withRun
allows you to overwrite the CMD of the zap-container. Check this API-documentation.
You could directly pass the zap command in the withRun
part:
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090 -v $WORKSPACE:/zap/wrk:rw', 'zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true') { c ->
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090
-X POST https://my.fqdn.net/api/rest/sessions
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
withRun
allows you to overwrite the CMD of the zap-container. Check this API-documentation.
answered Nov 20 '18 at 16:03
fabfab
90811224
90811224
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394538%2fjenkins-docker-sidecar-with-container-running-a-daemon-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown