Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-36332

Allow a command argument to be passed to Image.withRun

    XMLWordPrintable

Details

    Description

      As a user of docker.WithRun, I Should Be Able To specify command arguments for the Docker run So That I Can provide arguments to containers that are meant to be run like commands (e.g have custom entrypoints defined).

      == Acceptance Criteria ==
      Given I run a docker container
      When I run the Groovy syntax of docker.image(busybox).withRun(args: "-v /tmp:/tmp", command: "ls -la /tmp")
      Then I expect the underlying docker run command to look like the following "docker run -d -v /tmp:/tmp busybox ls -la /tmp"

      === Notes ====
      Expand arguments to https://github.com/jenkinsci/docker-workflow-plugin/blob/153c70d5e863eb499b49d08d6992f3eff3ca586a/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy#L133 to allow "command" optional argument as well.

      Attachments

        Issue Links

          Activity

            covalence Domingo K added a comment -

            jglick - are there steps anywhere to fork/build/install this workflow plugin until this issues is resolved?

            covalence Domingo K added a comment - jglick - are there steps anywhere to fork/build/install this workflow plugin until this issues is resolved?
            jglick Jesse Glick added a comment -

            withRun is merely sugar for run—which already allows a command to be specified—followed by a stop in a finally block. So just use

            def c = docker.image(busybox).run('-v /tmp:/tmp', 'ls -la /tmp')
            try {
              // use c as you like
            } finally {
              c.stop()
            }
            
            jglick Jesse Glick added a comment - withRun is merely sugar for run —which already allows a command to be specified—followed by a stop in a finally block. So just use def c = docker.image(busybox).run( '-v /tmp:/tmp' , 'ls -la /tmp' ) try { // use c as you like } finally { c.stop() }
            jglick Jesse Glick added a comment -

            (And run itself is merely sugar for sh 'docker run …'. You can always fall back to using any Docker CLI shell commands you like in this plugin.)

            jglick Jesse Glick added a comment - (And run itself is merely sugar for sh 'docker run …' . You can always fall back to using any Docker CLI shell commands you like in this plugin.)
            jglick Jesse Glick added a comment -

            As of JENKINS-33063 in 1.5, anyway.

            jglick Jesse Glick added a comment - As of JENKINS-33063 in 1.5, anyway.

            Code changed in jenkins
            User: Christian Alonso Chavez Ley
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly
            src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java
            http://jenkins-ci.org/commit/docker-workflow-plugin/770f038a72c3bbeb3fb173167546839d596aa129
            Log:
            JENKINS-36332 I would like to apply the same command parameter that's used in JENKINS-33063 to the "withRun" method so that I can clean up most of my containers as soon as they're finished.
            Given that I also kind of need this I just PR my take on the solution

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christian Alonso Chavez Ley Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/770f038a72c3bbeb3fb173167546839d596aa129 Log: JENKINS-36332 I would like to apply the same command parameter that's used in JENKINS-33063 to the "withRun" method so that I can clean up most of my containers as soon as they're finished. Given that I also kind of need this I just PR my take on the solution

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly
            src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java
            http://jenkins-ci.org/commit/docker-workflow-plugin/668cfa3bc6dab0775e63141642d4d07901854608
            Log:
            Merge pull request #58 from cachavezley/master

            JENKINS-36332 Allow a command argument to be passed to Image.withRun

            Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/5f729d7ec2bb...668cfa3bc6da

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy src/main/resources/org/jenkinsci/plugins/docker/workflow/DockerDSL/help.jelly src/test/java/org/jenkinsci/plugins/docker/workflow/DockerDSLTest.java http://jenkins-ci.org/commit/docker-workflow-plugin/668cfa3bc6dab0775e63141642d4d07901854608 Log: Merge pull request #58 from cachavezley/master JENKINS-36332 Allow a command argument to be passed to Image.withRun Compare: https://github.com/jenkinsci/docker-workflow-plugin/compare/5f729d7ec2bb...668cfa3bc6da

            People

              cachavezley Christian Alonso Chavez Ley
              covalence Domingo K
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: