I am trying to configure my GitLab CI to automatically build my Elixir app and create new release each time when it succeed on master
branch. However whenever it comes to deployment it fails due to an old Git repository on build server.
My .gitlab-ci.yml
configuration:
image: 'elixir:1.3.3'
services:
- postgres
# …
staging:
stage: deploy
environment: staging
tags:
- elixir
before_script:
- mix local.hex --force
- mix do deps.get, compile
- 'which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)'
- eval $(ssh-agent -s)
- echo "$SSH_DEPLOY_STAGING_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
script:
- mix edeliver build release --revision=$CI_BUILD_REF --auto-version=git-revision
- mix edeliver deploy to staging
only:
- master
cache:
paths:
- _build/
- deps/
And output of edeliver
on CI (app builder is Distillery):
$ which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 373
$ echo "$SSH_DEPLOY_STAGING_KEY" | tr -d '\r' | ssh-add -
Identity added: (stdin) (hauleth@niuniobook)
$ mkdir -p ~/.ssh
$ mix edeliver build release --revision=$CI_BUILD_REF --auto-version=git-revision
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
BUILDING RELEASE OF ONEMEDICAL APP ON BUILD HOST
-----> Authorizing hosts
-----> Ensuring hosts are ready to accept git pushes
-----> Pushing new commits with git to: [email protected]
-----> Resetting remote hosts to 3faf1d077f95ce7207cac7d14dd25b33d648d710
fatal: Could not parse object '3faf1d077f95ce7207cac7d14dd25b33d648d710'.
A remote command failed on:
[email protected]
Output of the command is shown above and the command executed
on that host is printed below for debugging purposes:
FAILED with exit status 128:
set -e
cd /tmp/edeliver/app/builds
git reset --hard 3faf1d077f95ce7207cac7d14dd25b33d648d710
ERROR: Build failed: exit code 1
Locally when I run mix edeliver build
everything works smoothly but I cannot find why when running via CI this fails.