From 542433406e647d93267cfc45e401c01f7d2c53e1 Mon Sep 17 00:00:00 2001 From: Nick Medveditskov <Nickolaim@users.noreply.github.com> Date: Mon, 3 Dec 2018 09:50:07 -0800 Subject: [PATCH] Define USER and BRANCH in the Docker image (#393) * Error message if Travis CI is run in a forked environment * Add USER and BRANCH args in Docker file. The default behavior has not changed * Add a condition branch for no PR and master branch - address PR feedback --- .travis.yml | 1 + Dockerfile | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c76677f..43a53135 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ notifications: - matthew.k.hansen@intel.com before_install: + - if [ "${TRAVIS_REPO_SLUG}" != "ros-planning/navigation2" ]; then echo "Travis CI is supported only in ros-planning/navigation2" && exit 1; fi - docker build -t nav2:latest --build-arg PULLREQ=$TRAVIS_PULL_REQUEST . script: diff --git a/Dockerfile b/Dockerfile index 1fbfe15d..abe33cb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,20 +60,27 @@ RUN apt-get install -y \ # get the latest nightly ROS2 build -> ros2_ws/ros2_linux WORKDIR /ros2_ws -RUN wget -nv https://ci.ros2.org/view/packaging/job/packaging_linux/lastSuccessfulBuild/artifact/ws/ros2-package-linux-x86_64.tar.bz2 +RUN wget -nv -t 5 https://ci.ros2.org/view/packaging/job/packaging_linux/lastSuccessfulBuild/artifact/ws/ros2-package-linux-x86_64.tar.bz2 RUN tar -xjf ros2-package-linux-x86_64.tar.bz2 # clone navigation2 repo WORKDIR /ros2_ws/navigation2_ws/src -RUN git clone https://github.com/ros-planning/navigation2.git +ARG USER=ros-planning +RUN git clone https://github.com/$USER/navigation2.git # change to correct branch if $BRANCH is not = master WORKDIR /ros2_ws/navigation2_ws/src/navigation2 ARG PULLREQ=false +ARG BRANCH=master RUN echo "pullreq is $PULLREQ" -RUN if [ "$PULLREQ" == "false" ]; \ - then \ +RUN if [ "$PULLREQ" == "false" ] && [ "$BRANCH" == "master" ]; then \ echo "No pull request number given - defaulting to master branch"; \ + elif [ "$BRANCH" != "master" ]; then \ + cd navigation2; \ + git fetch origin $BRANCH:temp_branch; \ + git checkout temp_branch; \ + cd -; \ + echo "No pull request number given - defaulting to $BRANCH branch"; \ else \ git fetch origin pull/$PULLREQ/head:pr_branch; \ git checkout pr_branch; \ -- GitLab