1

I'm here to try to understand what's wrong with my CICD.

The context:

  • source code is hosted into à private GITLAB projet
  • web app (laravel/php) is hosted by GANDI (simplehosting)
  • on simplehosting offer, it is possible to deploy application using GIT

My target is to manage a cicd pipeline (using gitlab-ci) in order to check code quality, run unit tests and deploy automatically on a test/stage environnement. And later deploy on production on manual action.

My is issue is on deploy stage: How to push (deploy) my gitlab repo into the hosting git?

My initial concern was that there is nothing to push (view from my runner/image). I had and src refspec error.

$ git push gandi master
error: src refspec master does not match any.
error: failed to push some refs to 'git+ssh://xxx@git.sd6.gpaas.net/test.domain.tl.git'
ERROR: Job failed: exit code 1

I tried a solution proposed in 4181861 using HEAD: option in my git push.
And the Job succeeded.
But ... there is NO UPDATE on the hosting server!!

I understand that there is no update to push on the runner point of view.

$ git status
HEAD detached at ff1ce8c
nothing to commit, working tree clean

So what to do?
I'm looking for new avenues to explore.


My gitlab-ci.yml

image: php:latest

before_script:
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
  - mkdir -p ~/.ssh
  - eval $(ssh-agent -s)
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  - ssh-add <(echo "$SSH_PRIVATE_KEY")

stages:
  - deploy

job_deploy_staging:
  stage: deploy
  script:
    - echo "Deploy the app into (gandi) staging environnement"
    - git config --global user.email "$GIT_EMAIL" && git config --global user.name "$GIT_NAME"
    - git remote add gandi git+ssh://$GANDI_USER@$GANDI_GITSERVER/$GANDI_GITREPO_TEST
    - git status
    - git show
    - git push gandi HEAD:master
  environment:
    name: staging
    url : http://test.domain.tl
  only:
    - master


job_deploy_prod:
  stage: deploy
  script:
    - echo "Deploy the app into (gandi) production environnement"
    - git config --global user.email "$GIT_EMAIL" && git config --global user.name "$GIT_NAME"
    - git remote add gandi git+ssh://$GANDI_USER@$GANDI_GITSERVER/$GANDI_GITREPO_PROD
    - git push gandi master
  environment:
    name: production
    url : http://www.domain.tl
  when: manual
  only:
    - master
jhs
  • 13
  • 3
  • You have to checkout full git repo. Do `GIT_STRATEGY: clone`, otherwise the tree is only fetch. `'[[ -f ... '` - no need to quote, you can remove the `'`. – KamilCuk Jul 17 '20 at 07:14

0 Answers0