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

Dockerfile ADD command is not getting well interpreted when using it on array format

      When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

      The following instruction inside Dockerfile should copy a file to inside the image using the star wildcard:

      ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]
      

      When I build the image with docker official client (via command line "docker build .") it works just fine but when using the Create Image job it doest not create the image, the console output is:

      17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
      17:54:45 Step 0 : FROM java:7
      17:54:45 
      17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
      

      So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:

      import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
      import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
      import javax.json.Json
      import javax.json.JsonObject
      
      def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
      def tag = 'myhub/myapp:master'
      
      def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
      def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
      def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
      def inputStr
      while ((inputStr = streamReader.readLine()) != null) {
          def json = Json.createReader(new StringReader(inputStr)).readObject()
          println json
      }
      

      And the output shows that the command is not being well interpreted as the docker client does:

      [stream:"Step 0 : FROM java:7\n"]
      [stream:" ---> 0ad6528abdca\n"]
      [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
      [stream:" ---> Running in da3b218202ec\n"]
      [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
      [stream:"\u001b[91mLocal time is now:      Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now:  Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
      [stream:"\u001b[91m\n\u001b[0m"]
      [stream:" ---> 05f2f338869a\n"]
      [stream:"Removing intermediate container da3b218202ec\n"]
      [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
      [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
      

      Temporarily I rewrote my instruction to be just a plain command (not array format) in order to make it work, but I think that the plugin should be 100% compatible with docker instructions.

      The plugin should show the error message on the build console as well.

          [JENKINS-30533] Dockerfile ADD command is not getting well interpreted when using it on array format

          tiago oliveira created issue -
          tiago oliveira made changes -
          Description Original: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }

          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]

          And the add command, as can be seen, is not being well interpreted.
          New: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'


          {code:groovy}
          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}


          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]

          And the add command, as can be seen, is not being well interpreted.
          tiago oliveira made changes -
          Description Original: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'


          {code:groovy}
          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}


          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]

          And the add command, as can be seen, is not being well interpreted.
          New: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}


          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          And the add command, as can be seen, is not being well interpreted.
          tiago oliveira made changes -
          Description Original: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}


          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          And the add command, as can be seen, is not being well interpreted.
          New: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}
          {code}
          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          And the add command, as can be seen, is not being well interpreted.
          tiago oliveira made changes -
          Description Original: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}
          {code}
          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:


          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          And the add command, as can be seen, is not being well interpreted.
          New: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          {code:none}
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]
          {code}

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          {code}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:

          {code:none}
          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          And the add command, as can be seen, is not being well interpreted.
          tiago oliveira made changes -
          Description Original: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy the file to the image using the start wildcard:
          {code:none}
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]
          {code}

          When I build the image with docker command it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          17:55:24 [Docker] INFO: Pushing image myhub/app
          17:55:24 [Docker] INFO: {"status":"The push refers to a repository [myhub/app] (len: 0)"}
          17:55:24 [Docker] INFO: {"errorDetail":{"message":"Repository does not exist: myhub/app"},"error":"Repository does not exist: myhub/app"}

          {code}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:

          {code:none}
          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          And the add command, as can be seen, is not being well interpreted.
          New: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy a file to inside the image using the star wildcard:
          {code:none}
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]
          {code}

          When I build the image with docker official client (via command line "docker build .") it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          {code}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:

          {code:none}
          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          And the output shows that the command is not being well interpreted as the docker client does:

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          Temporarily I rewrote my instruction to be just a plain command (not array format) in order to make it work, but I think that the plugin should be 100% compatible with docker instructions.
          tiago oliveira made changes -
          Description Original: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy a file to inside the image using the star wildcard:
          {code:none}
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]
          {code}

          When I build the image with docker official client (via command line "docker build .") it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          {code}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:

          {code:none}
          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          And the output shows that the command is not being well interpreted as the docker client does:

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          Temporarily I rewrote my instruction to be just a plain command (not array format) in order to make it work, but I think that the plugin should be 100% compatible with docker instructions.
          New: When using ADD instruction inside Dockerfile in a form of array parameter, the docker client is returning and error message, but that message is not being showed on the build console.

          The following instruction inside Dockerfile should copy a file to inside the image using the star wildcard:
          {code:none}
          ADD ["target/myapp-*.tar.gz", "/usr/local/apps/"]
          {code}

          When I build the image with docker official client (via command line "docker build .") it works just fine but when using the Create Image job it doest not create the image, the console output is:

          {code:none}
          17:54:39 [Docker] INFO: Creating docker image from /var/lib/jenkins/jobs/app/workspace
          17:54:45 Step 0 : FROM java:7
          17:54:45
          17:55:24 [Docker] INFO: Sucessfully created image myhub/app:master
          {code}

          So I wrote a small script in order to run inside the Jenkins console and extract the result of the Create image build:

          {code:none}
          import org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand
          import org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
          import javax.json.Json
          import javax.json.JsonObject

          def path = '/data/var/lib/jenkins/jobs/myapp/workspace/'
          def tag = 'myhub/myapp:master'

          def client = Jenkins.getInstance().getDescriptor(DockerBuilder.class).getDockerClient(null)
          def istream = client.buildImageCmd(new File(path)).withTag(tag).withNoCache(true).withRemove(true).exec()
          def streamReader = new BufferedReader(new InputStreamReader(istream, "UTF-8"))
          def inputStr
          while ((inputStr = streamReader.readLine()) != null) {
              def json = Json.createReader(new StringReader(inputStr)).readObject()
              println json
          }
          {code}

          And the output shows that the command is not being well interpreted as the docker client does:

          {code:none}
          [stream:"Step 0 : FROM java:7\n"]
          [stream:" ---> 0ad6528abdca\n"]
          [stream:"Step 1 : RUN echo \"America/Sao_Paulo\" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata\n"]
          [stream:" ---> Running in da3b218202ec\n"]
          [stream:"\u001b[91m\nCurrent default time zone: 'America/Sao_Paulo'\n\u001b[0m"]
          [stream:"\u001b[91mLocal time is now: Thu Sep 17 18:31:24 BRT 2015.\nUniversal Time is now: Thu Sep 17 21:31:24 UTC 2015.\n\u001b[0m"]
          [stream:"\u001b[91m\n\u001b[0m"]
          [stream:" ---> 05f2f338869a\n"]
          [stream:"Removing intermediate container da3b218202ec\n"]
          [stream:"Step 2 : ADD target/myapp*-all.tar.gz /usr/local/apps/\n"]
          [errorDetail:[message:"No source files were specified"], error:"No source files were specified"]
          {code}

          Temporarily I rewrote my instruction to be just a plain command (not array format) in order to make it work, but I think that the plugin should be 100% compatible with docker instructions.

          The plugin should show the error message on the build console as well.
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 165644 ] New: JNJira + In-Review [ 182066 ]

            vjuranek vjuranek
            tiagodeoliveira tiago oliveira
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: