I'm trying to run travis build on my local machine using their docker images (Their docker images). Their instructions are here.
I was able to download and run the docker machine, I switched to travis
user, and clone my repo. But I don't quite understand how to run the travis.yml file so that the build will start.
I already searched and try using travis-cli
and travis-build
but with no success. I'm open to suggestions about interacting with travis build (using the command line of course) before/while/after running travis (for faster debugging).
I managed to puzzle together a Dockerfile from various sources and some on my own. There are two images: one base for travis
being available and one project specific for "org/repo" GitHub project (make sure occurrences are replaced with a real project name). It uses the local uncommitted repository version (hence the sed
s). After travis-local-build
is up and running ./build.sh
will trigger a CI build similar to travis-ci.org.
#!docker build -f Dockerfile.travis-local -t travis-local .
FROM travisci/ci-amethyst:packer-1512508255-986baf0
USER travis
WORKDIR /home/travis
RUN git clone https://github.com/travis-ci/travis-build.git
WORKDIR travis-build
RUN bash -lc "gem install travis"
RUN bash -lc travis # to create ~/.travis
RUN ln -s $(pwd) ~/.travis/travis-build
RUN bash -lc "bundle install"
#RUN bash -lc "bundler add travis"
RUN bash -lc "bundler binstubs travis"
RUN echo alias travis="~/.travis/travis-build/bin/travis" >> ~/.bashrc
#!docker build -f Dockerfile.travis-local-build -t travis-local-build . && docker run -ti travis-local-build
FROM travis-local
USER travis
WORKDIR /home/travis/build
ADD --chown=travis . org/repo
WORKDIR org/repo
RUN chmod +x gradlew
# Alias not recognized, but in interactive mode `travis compile` works without path.
RUN bash -lc "~/.travis/travis-build/bin/travis compile --no-interactive > build.sh"
RUN sed -re 's/^.*travis_wait_for_network '\''.*$/echo DISABLED &/mg' build.sh --in-place
RUN sed -re 's/^.*apt-get update.*$/echo DISABLED &/mg' build.sh --in-place
RUN sed -re 's/^.*travis_cmd git.*(fetch|reset|checkout).*$/echo DISABLED &/mg' build.sh --in-place
RUN chmod +x build.sh
WORKDIR /home/travis/build
RUN sudo ln -s org/repo/build.sh build.sh
CMD ["bash"]
Disclaimer: I'm new to Docker, only been using it for a few hours, so I might have gotten some concepts wrong. Any pointers appreciated in comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With