DockerHub autobuild for a GitHub pull request - using the $DOCKER_TAG variable?docker autobuild with git private submoduleIn a Dockerfile, How to update PATH environment variable?Where should i run my grunt build step when building my docker image for staging and production environments?Writing Dockerfile for Dockerhub Automated buildsDocker on RHEL 7 in AWS can’t pull imagesDocker workflow for automated builds on Github-DockerhubDocker daemon using several registriesHow can I make Jenkins aware of Dockerhub's webhook?Can't Access Private MySQL Docker Image From Gitlab CISingle dockerfiles GitHub repository + Docker Hub automated builds

Hail hit my roof. Do I need to replace it?

How to convert diagonal matrix to rectangular matrix

What was this character's plan?

An integral that needs subtitution to be solved.

What happens to unproductive professors?

Moving millions of files to a different directory with specfic name patterns

How to evaluate the performance of open source solver?

Party going through airport security at separate times?

Why did Dumbledore ignore this line?

Restrict Access to internet for all MAC except listed on LINKSYS Wireless-N ADSL2+ Modem Router

Transpose matrices and vectors - rules

Finding overlapping polygons in two shapefiles and deleting them in R?

This LM317 diagram doesn't make any sense to me

How many tone holes are there actually in different orchestral woodwind instruments?

Did the Ottoman empire suppress the printing press?

Non-Chromatic Orchestral Instruments?

Swapping "Good" and "Bad"

User Vs. Connected App

Estimates on number of topologies on a finite set

Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?

Password Hashing Security Using Scrypt & Argon2

What is the problem here?(all integers are irrational proof...i think so)

How was the Shuttle loaded and unloaded from its carrier aircraft?

Users forgetting to regenerate PDF before sending it



DockerHub autobuild for a GitHub pull request - using the $DOCKER_TAG variable?


docker autobuild with git private submoduleIn a Dockerfile, How to update PATH environment variable?Where should i run my grunt build step when building my docker image for staging and production environments?Writing Dockerfile for Dockerhub Automated buildsDocker on RHEL 7 in AWS can’t pull imagesDocker workflow for automated builds on Github-DockerhubDocker daemon using several registriesHow can I make Jenkins aware of Dockerhub's webhook?Can't Access Private MySQL Docker Image From Gitlab CISingle dockerfiles GitHub repository + Docker Hub automated builds






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have a project with DockerHub autobuilds running for each branch of the project. These builds are running nicely.



I would like to extend this autobuild configuration to build images for selected pull requests for these branches.



enter image description here



The following documentation indicates that a variable named DOCKER_TAG should be available in a DockerHub autobuild.



https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing



I want to configure my auto build in the following manner.



If I attempt to build a tag named "pr1234" then my build will overlay the code from PR #1234 before running the build.



# Assign the env variable DOCKER_TAG to an arg of the same name
ARG DOCKER_TAG=$DOCKER_TAG

...

# if DOCKER_TAG is in the format prNNNN then merge code for that PR on top of the current branch
RUN PRNUM=`echo $DOCKER_TAG| egrep "^pr([0-9]+)$" | sed -e s/pr//` &&
if [ -n "$PRNUM" ];
then echo "Merging $PRNUM";
curl -o /tmp/pr.patch -L https://github.com/DSpace/DSpace/pull/$PRNUM.diff;
git apply /tmp/pr.patch;
fi


If I run my build locally, I am able to set this variable and my docker build runs as I would like.



docker build -t dspace/dspace:pr1234 -f Dockerfile.jdk8-test --build-arg DOCKER_TAG=pr1234 .


When I attempt to run this from Dockerhub, the DOCKER_TAG variable appears to be blank, so I presume that DOCKER_TAG is not being set as I expected.



Can you suggest a way to access this variable or to accomplish an automated build for selected PR's?










share|improve this question




























    1















    I have a project with DockerHub autobuilds running for each branch of the project. These builds are running nicely.



    I would like to extend this autobuild configuration to build images for selected pull requests for these branches.



    enter image description here



    The following documentation indicates that a variable named DOCKER_TAG should be available in a DockerHub autobuild.



    https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing



    I want to configure my auto build in the following manner.



    If I attempt to build a tag named "pr1234" then my build will overlay the code from PR #1234 before running the build.



    # Assign the env variable DOCKER_TAG to an arg of the same name
    ARG DOCKER_TAG=$DOCKER_TAG

    ...

    # if DOCKER_TAG is in the format prNNNN then merge code for that PR on top of the current branch
    RUN PRNUM=`echo $DOCKER_TAG| egrep "^pr([0-9]+)$" | sed -e s/pr//` &&
    if [ -n "$PRNUM" ];
    then echo "Merging $PRNUM";
    curl -o /tmp/pr.patch -L https://github.com/DSpace/DSpace/pull/$PRNUM.diff;
    git apply /tmp/pr.patch;
    fi


    If I run my build locally, I am able to set this variable and my docker build runs as I would like.



    docker build -t dspace/dspace:pr1234 -f Dockerfile.jdk8-test --build-arg DOCKER_TAG=pr1234 .


    When I attempt to run this from Dockerhub, the DOCKER_TAG variable appears to be blank, so I presume that DOCKER_TAG is not being set as I expected.



    Can you suggest a way to access this variable or to accomplish an automated build for selected PR's?










    share|improve this question
























      1












      1








      1


      1






      I have a project with DockerHub autobuilds running for each branch of the project. These builds are running nicely.



      I would like to extend this autobuild configuration to build images for selected pull requests for these branches.



      enter image description here



      The following documentation indicates that a variable named DOCKER_TAG should be available in a DockerHub autobuild.



      https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing



      I want to configure my auto build in the following manner.



      If I attempt to build a tag named "pr1234" then my build will overlay the code from PR #1234 before running the build.



      # Assign the env variable DOCKER_TAG to an arg of the same name
      ARG DOCKER_TAG=$DOCKER_TAG

      ...

      # if DOCKER_TAG is in the format prNNNN then merge code for that PR on top of the current branch
      RUN PRNUM=`echo $DOCKER_TAG| egrep "^pr([0-9]+)$" | sed -e s/pr//` &&
      if [ -n "$PRNUM" ];
      then echo "Merging $PRNUM";
      curl -o /tmp/pr.patch -L https://github.com/DSpace/DSpace/pull/$PRNUM.diff;
      git apply /tmp/pr.patch;
      fi


      If I run my build locally, I am able to set this variable and my docker build runs as I would like.



      docker build -t dspace/dspace:pr1234 -f Dockerfile.jdk8-test --build-arg DOCKER_TAG=pr1234 .


      When I attempt to run this from Dockerhub, the DOCKER_TAG variable appears to be blank, so I presume that DOCKER_TAG is not being set as I expected.



      Can you suggest a way to access this variable or to accomplish an automated build for selected PR's?










      share|improve this question














      I have a project with DockerHub autobuilds running for each branch of the project. These builds are running nicely.



      I would like to extend this autobuild configuration to build images for selected pull requests for these branches.



      enter image description here



      The following documentation indicates that a variable named DOCKER_TAG should be available in a DockerHub autobuild.



      https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing



      I want to configure my auto build in the following manner.



      If I attempt to build a tag named "pr1234" then my build will overlay the code from PR #1234 before running the build.



      # Assign the env variable DOCKER_TAG to an arg of the same name
      ARG DOCKER_TAG=$DOCKER_TAG

      ...

      # if DOCKER_TAG is in the format prNNNN then merge code for that PR on top of the current branch
      RUN PRNUM=`echo $DOCKER_TAG| egrep "^pr([0-9]+)$" | sed -e s/pr//` &&
      if [ -n "$PRNUM" ];
      then echo "Merging $PRNUM";
      curl -o /tmp/pr.patch -L https://github.com/DSpace/DSpace/pull/$PRNUM.diff;
      git apply /tmp/pr.patch;
      fi


      If I run my build locally, I am able to set this variable and my docker build runs as I would like.



      docker build -t dspace/dspace:pr1234 -f Dockerfile.jdk8-test --build-arg DOCKER_TAG=pr1234 .


      When I attempt to run this from Dockerhub, the DOCKER_TAG variable appears to be blank, so I presume that DOCKER_TAG is not being set as I expected.



      Can you suggest a way to access this variable or to accomplish an automated build for selected PR's?







      docker dockerhub






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 23:18









      terrywbterrywb

      2,6151 gold badge10 silver badges30 bronze badges




      2,6151 gold badge10 silver badges30 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          2














          I found a solution that seems to work. I created a build hook named hooks/build and pass the variable explicitly.



          #!/bin/bash
          docker build --build-arg DOCKER_TAG=$DOCKER_TAG -f $DOCKERFILE_PATH -t $IMAGE_NAME .


          See https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks






          share|improve this answer

























          • Thanks for your answer. That helps me out the issue.

            – Bowen
            May 11 at 10:39










          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347752%2fdockerhub-autobuild-for-a-github-pull-request-using-the-docker-tag-variable%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









          2














          I found a solution that seems to work. I created a build hook named hooks/build and pass the variable explicitly.



          #!/bin/bash
          docker build --build-arg DOCKER_TAG=$DOCKER_TAG -f $DOCKERFILE_PATH -t $IMAGE_NAME .


          See https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks






          share|improve this answer

























          • Thanks for your answer. That helps me out the issue.

            – Bowen
            May 11 at 10:39















          2














          I found a solution that seems to work. I created a build hook named hooks/build and pass the variable explicitly.



          #!/bin/bash
          docker build --build-arg DOCKER_TAG=$DOCKER_TAG -f $DOCKERFILE_PATH -t $IMAGE_NAME .


          See https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks






          share|improve this answer

























          • Thanks for your answer. That helps me out the issue.

            – Bowen
            May 11 at 10:39













          2












          2








          2







          I found a solution that seems to work. I created a build hook named hooks/build and pass the variable explicitly.



          #!/bin/bash
          docker build --build-arg DOCKER_TAG=$DOCKER_TAG -f $DOCKERFILE_PATH -t $IMAGE_NAME .


          See https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks






          share|improve this answer















          I found a solution that seems to work. I created a build hook named hooks/build and pass the variable explicitly.



          #!/bin/bash
          docker build --build-arg DOCKER_TAG=$DOCKER_TAG -f $DOCKERFILE_PATH -t $IMAGE_NAME .


          See https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 14:19

























          answered Mar 26 at 4:38









          terrywbterrywb

          2,6151 gold badge10 silver badges30 bronze badges




          2,6151 gold badge10 silver badges30 bronze badges












          • Thanks for your answer. That helps me out the issue.

            – Bowen
            May 11 at 10:39

















          • Thanks for your answer. That helps me out the issue.

            – Bowen
            May 11 at 10:39
















          Thanks for your answer. That helps me out the issue.

          – Bowen
          May 11 at 10:39





          Thanks for your answer. That helps me out the issue.

          – Bowen
          May 11 at 10:39








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347752%2fdockerhub-autobuild-for-a-github-pull-request-using-the-docker-tag-variable%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript