title: GitLab-CI Push Branch to Remote on Deploy
body: <p>So, I'm running GitLab CI on Enterprise Edition to build my project and then deploy on success.</p>
  
  <p>I have two problems:
   1. I cannot <code>git push</code> my branch to a secure SSH remote.
   2. How do I force it to only deploy on a successful build?</p>
  
  <p>Here is my current configuration:</p>
  
  <pre><code>stages:
    - build
    - deploy
  
  services:
    - mysql:latest
  
  variables:
    MYSQL_DATABASE: el_duderino
    MYSQL_ROOT_PASSWORD: mysql_strong_password
  
  node:
    image: monostream/nodejs-gulp-bower
    stage: build
    script:
      - npm install
      - bower install --allow-root
      - gulp
  
  migrations:
    image: eboraas/laravel
    stage: build
    script:
      - composer install
      - cp .env.testing .env
      - php artisan key:generate
      - php artisan migrate --force
      - echo "Done!"
  
  deploy_test:
    stage: deploy
    script:
      - echo "Deploy to test server."
      - git remote set-url test ssh://git@10.16.0.148/var/repo/subPortalTest.git
      - git push test master
    environment:
      name: Test
      url: http://10.16.0.148/
    only:
      - master
  </code></pre>
  
  <p>My <code>deploy_test</code> job fails and returns the following:</p>
  
  <blockquote>
    <p>Host key verification failed.</p>
    
    <p>fatal: Could not read from remote repository.</p>
    
    <p>Please make sure you have the correct access rights and the repository
    exists.</p>
  </blockquote>