GitLab deploy job fetches changes from git - gitlab-ci

In my project, the deploy script uses the results of the build job, but I see that on my deploy job GitLab CI refetches all changes from the last commit and also removes all files produced by the build job. I am using the Shell Executor.
Is there a way to prevent GitLab CI from doing this on the deploy job, so that my deploy can just continue from where my build job left off?
I have tried:
cache:
untracked: true
on my deploy job, but it did not seem to make any difference
my complete .gitlab-ci.yml is:
before_script:
- sudo apt-get -y install default-jdk
- sudo add-apt-repository -y ppa:cwchien/gradle
- sudo apt-get -y update
- sudo apt-get -y install gradle
- curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
- sudo apt-get install -y nodejs
- sudo npm install -g pm2
stages:
- build
- test
- deploy
after_script:
jobBuild:
stage: build
script:
- ( cd my-lib; gradle build assemble)
only:
- master
jobDeploy:
before_script:
stage: deploy
cache:
untracked: true
script:
- <some shell scripts>
only:
- master

More info on Gitlab CI cache
First, since it's the files from the build job you want to cache, you may want to add the cache rule to jobBuild. You could even define the cache globally by defining it outside a job.
The problem with the caching mechanism is that it's a best effort system, meaning the cache might not always be available.
The cache is provided on a best-effort basis, so don't expect that the
cache will be always present. For implementation details, please check
GitLab Runner.
If you want something that will transfer built files from one job to another 100% of the time, you need to use artifacts.
Using artifacts
Gitlab CI will let you define a set of files and/or folders to bundle into an artifact at the end of a job. That artifact will then be available to use in jobs of later stages provided you specify a dependency on the first job.
If you don't want to fetch the git repo in the deploy stage, you can set your GIT_STRATEGY to none. More info on this here.
Here's a modification of your .gitlab-ci.yml file to do all that:
before_script:
- sudo apt-get -y install default-jdk
- sudo add-apt-repository -y ppa:cwchien/gradle
- sudo apt-get -y update
- sudo apt-get -y install gradle
- curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
- sudo apt-get install -y nodejs
- sudo npm install -g pm2
stages:
- build
- test
- deploy
after_script:
jobBuild:
stage: build
script:
- ( cd my-lib; gradle build assemble)
only:
- master
artifacts:
paths:
- path/to/folder/containing/build/files # for example my-lib
jobDeploy:
before_script:
stage: deploy
variables:
GIT_STRATEGY: none
dependencies:
- jobBuild
script:
- cd path/to/folder/containing/build/files # for example my-lib
- <some shell scripts>
only:
- master

Related

My test stage in GitLab CI won't get picked up by the pipeline

I'm trying to have 2 types of tests run depending on why the pipeline is being run. On commits I'd like to run my build stage, and on merge requests I'd like to run my build and test stages. When I do a commit it runs only build but it also only runs build on Merge Requests.
I've tried specifying only:merge_requests in my .gitlab-ci.yml but it still won't register the stage.
stages:
- build
- deploy
- test
- deploy_prod
build:
image: "python:3.6.1"
stage: build
variables:
GIT_SUBMODULE_STRATEGY: 'recursive'
script:
- pip install --upgrade pip
- pip install -r lender_v2/requirements.txt
- pip install -r lender_v2/reggora_models/requirements.txt
- export FLASK_CONFIG=localhost
- cd lender_v2/smoke_tests && python3 -m unittest discover -p "smoke_*.py" -q --failfast
test:
image: "python:3.6.1"
stage: test
variables:
GIT_SUBMODULE_STRATEGY: 'recursive'
script:
- pip install --upgrade pip
- pip install -r lender_v2/requirements.txt
- pip install -r lender_v2/reggora_models/requirements.txt
- export FLASK_CONFIG=localhost
- cd lender_v2/test_project && python3 -m unittest discover ../test_project -p "test_*.py" -q --failfast
only:
- merge_requests
I thought this should run the test stage on merge_requests but it won't run at any time.
Which GitLab and GitLab runner versions are you using?
only: merge_requests was introduced in Gitlab 11.6.
Also, note the information from the Docs:
As of GitLab 11.10, pipelines for merge requests require GitLab Runner
11.9 or higher due to the recent refspecs changes. Anything lower will cause the pipeline to fail.
Gitlab documentation recommends using 'rules' instead of 'only'. You can accomplish only merge_requests by doing the following:
stages:
- build
- deploy
- test
- deploy_prod
build:
image: "python:3.6.1"
stage: build
variables:
GIT_SUBMODULE_STRATEGY: 'recursive'
script:
- pip install --upgrade pip
- pip install -r lender_v2/requirements.txt
- pip install -r lender_v2/reggora_models/requirements.txt
- export FLASK_CONFIG=localhost
- cd lender_v2/smoke_tests && python3 -m unittest discover -p "smoke_*.py" -q --failfast
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
test:
image: "python:3.6.1"
stage: test
variables:
GIT_SUBMODULE_STRATEGY: 'recursive'
script:
- pip install --upgrade pip
- pip install -r lender_v2/requirements.txt
- pip install -r lender_v2/reggora_models/requirements.txt
- export FLASK_CONFIG=localhost
- cd lender_v2/test_project && python3 -m unittest discover ../test_project -p "test_*.py" -q --failfast
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
https://docs.gitlab.com/ee/ci/yaml/#workflowrules

Docker container CentOs with Apache

I'm toying around with Docker. But i have an issue with Docker when trying to build a Centos and Apache Server in a container. I run Docker on my Windows 10 Machine.
The CentOS + Apache container, is coupled with a Maria DB image.
When i do the docker-compose my Apache container starts and imediateliy shut down with exit code 0.
Here's my dockerfile :
FROM centos:centos7
LABEL Author = "Aurelien H."
LABEL Description = "DOCKERFILE : Allows the creation of a Container with a Centreon distribution installed via packages"
#Update and install requirements
RUN yum update -y
RUN yum install -y wget nano centos-release-scl httpd git
#Install Centreon repo
RUN cd /usr/local/src
RUN wget http://yum.centreon.com/standard/3.4/el7/stable/noarch/RPMS/centreon-release-3.4-4.el7.centos.noarch.rpm
RUN yum install -y --nogpgcheck centreon-release-3.4-4.el7.centos.noarch.rpm
#Install Centreon
RUN yum install -y centreon-base-config-centreon-engine centreon centreon-pp-manager
RUN yum clean all
#RUN systemctl enable httpd.service
#RUN systemctl start httpd.service
EXPOSE 80
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
Here's my docker compose.
centreon:
build: ./centreon
ports:
- "80:80"
# volumes:
# - "./data"
links:
- mariadb
mariadb:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: notR00tPassword
I needed to use the "docker-compose up --build" command.
It rebuild the images before executing them.
Problem solved.

Unable to install required package (rabbitmq-server) before Travis CI build

Since today I experience the following issue with Travis CI: the required package specified in before_install section of .travis.yml:
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq rabbitmq-server
cannot be installed, breaking the build.
Response as shown Travis console log:
$ sudo apt-get update -qq
W: http://ppa.launchpad.net/couchdb/stable/ubuntu/dists/trusty/Release.gpg: Signature by key 15866BAFD9BCC4F3C1E0DFC7D69548E1C17EAB57 uses weak digest algorithm (SHA1)
$ sudo apt-get install -qq rabbitmq-server
E: Unable to correct problems, you have held broken packages.
The command "sudo apt-get install -qq rabbitmq-server" failed and exited with 100 during .
Your build has been stopped.
How would I overcome this problem? I have tried to replicate the issue locally, but it seems to be not reproducible.
I searched Google with this search string - "failed and exited with 100" apt install - this is the first hit:
https://github.com/travis-ci/travis-ci/issues/7998

drone build error: unable to locate package git

My drone.yml file is as follows..
Keep getting the error unable to locate package git.
Any suggestions?
pipeline:
build:
image: python:3.5.1-slim
commands:
- apt update && apt install git-core
- pip install -r requirements.txt
- nosetests --with-coverage --cover-erase --cover-package
Have you provided the full yaml? Because the example yaml fails with a Do you want to continue? [Y/n] Abort error message due to the fact that drone is running in non-interactive mode and cannot block and wait for user prompt to continue. It does not fail with the error message specified in the question.
You therefore need to run the command with -y like this:
pipeline:
build:
image: python:3.5.1-slim
commands:
- apt-get update
- apt-get install -y git-core
- which git
Which results in the following output in my logs:
+ which git
/usr/bin/git
Note that when drone runs your build it turns the commands into a simple shell script, starts the container, and executes the shell script as the entrypoint. So your yaml would turn into something like this:
#!/bin/sh
set -e
apt-get update
apt-get install -y git-core
which get
This means you should be able to test your commands directly from the command line in Docker to pinpoint what looks to be either an image or command issue:
$ docker run -t -i python:3.5.1-slim
# apt-get update && apt-get -y install git-core
# which git
I'm sorry this doesn't fully answer the question, but I was unable to repeat the same error message with the sample yaml provided in the question. If you can provide more clarify in your question, I can come back to this answer and edit in response

Travis CI for a Qt5 project

I am trying to use Travis CI with a Qt5 project, but I can't get the build to pass.
My .travis.yml
install:
- sudo apt-get update
- sudo apt-get install qt5-default qttools5-dev-tools
script:
- qmake -project
- qmake Ultron.pro
- make
Last segment of the error log:
0.58s$ sudo apt-get install qt5-default qttools5-dev-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package qt5-default
E: Unable to locate package qttools5-dev-tools
The command "sudo apt-get install qt5-default qttools5-dev-tools" failed and exited with 100 during .
Your build has been stopped.
Full log: http://pastebin.ubuntu.com/8296581/
Does this have something to do with it not being an official package?
You need to add the correct repository and update apt:
sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
sudo apt-get update -qq
Your .travis.yml will then look like:
before_install:
- sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
- sudo apt-get update -qq
- sudo apt-get install qtbase5-dev qtdeclarative5-dev libqt5webkit5-dev libsqlite3-dev
- sudo apt-get install qt5-default qttools5-dev-tools
script:
- qmake -project
- qmake Ultron.pro
- make
see: Travis CI config to build against Qt5.0 on Ubuntu 12.04. Requires installing a PPA and certain packages for qt5 support. (jreese / gist:6207161)