Unable to finish CI Job

Hello,
I have following .gitlab-ci.yml:

stages:
  - deploy
before_script:
  # Setup SSH deploy keys
  - 'which ssh-agent || ( apt-get install -qq openssh-client )'
  - eval $(ssh-agent -s)
  - ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 --decode)
    
deploy_staging:
  type: deploy
  environment:
    name: staging
    url: example.com
  script:
    - ssh -o StrictHostKeyChecking=no root@example.com "cd public_html/gitlab-test && git checkout master && git pull origin master && exit"
  only:
    - master

Everything works, but when all tasks are ended, runner still waiting:

Even timeout does’t work.

Anyone knows why?

Hi,

Could you provide us with some more information about the environment? Specifically, more information about the installation type, version info for both GitLab & the runner, the executor that you are utilizing, etc.

I recommend tailing the runner’s logs and enabling CI_DEBUG_TRACE within the job itself to get some verbose info from the build log. See this documentation for specifics.

Would you mind providing the etc/gitlab-runner/config.toml as well? Be sure to scrub out any sensitive information, like the token, before doing so.

You should also be able to see the communication from the runner and the GitLab instance within the access and the production log on the GitLab instance.

Hi,

Did you ever end up finding out what the issue was?

Yes,
I had to add line to killing ssh-agent:
- eval $(ssh-agent -k)

This is strange, because I didn’t see killing this proces in any example / tutorial. But for me, it sorted out the issue.

Final code:

stages:
  - deploy
before_script:
  # Setup SSH deploy keys
  - 'which ssh-agent || ( apt-get install -qq openssh-client )'
  - eval $(ssh-agent)
  - ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 --decode)

deploy_staging:
  type: deploy
  environment:
    name: staging
    url: example.com
  script:
    - ssh -o StrictHostKeyChecking=no root@example.com "cd public_html/gitlab-test && git checkout master && git pull origin master && exit 0"
    - eval $(ssh-agent -k)
  only:
    - master