title: GitLab: How can I use code from another repository in pipeline job?
body: <p>I have a GitLab project looking like this:
  <a href="https://i.stack.imgur.com/R2ZGK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R2ZGK.png" alt="enter image description here"></a></p>
  
  <p>During the build of both first-api and second-api I will need to execute the database-migration to be able to run integration tests with a database started as a service. </p>
  
  <p>Since the repository is public I tried to clone database-migration, build and then execute. Unfortionatly it fails on the clone step. This is from my .gitlab-ci.yml:</p>
  
  <pre><code>init_db:
    stage: build
    script:
      - git clone https://gitlab.com/groupname/database-migration.git
      - cd database-migration
      - mvn exec:java
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>$ git clone https://gitlab.com/groupname/database-migration.git
  Cloning into 'database-migration'...
  fatal: could not read Username for 'https://gitlab.com': No such device or address
  ERROR: Job failed: exit code 1
  </code></pre>
  
  <p>Is this the correct approach or is there a better solution? If this is the correct approach; how do I make it work?</p>
  
  <p><strong>Edit, trying submodules</strong></p>
  
  <p>After input that I should use submodules I changed my approach. 
  I have added a file <code>.gitmodules</code> to first-api looking like this:</p>
  
  <pre><code>[submodule "database-migration"]
    path = database-migration
    url = ../database-migration.git
  </code></pre>
  
  <p>In <code>.gitlab-ci.yml</code> I have the following:</p>
  
  <pre><code>image: maven:latest
  
  variables:
    GIT_SUBMODULE_STRATEGY: recursive
  
  init_db:
    stage: build
    script:
      - ls
      - cd database-migration
      - mvn exec:java
  </code></pre>
  
  <p>The job fails because the folder "database-migration" does not exist.</p>
  
  <p>If you want to look at the repository it can be  found <a href="https://gitlab.com/quizemon" rel="nofollow noreferrer">here</a>. I am trying to use submodules in "game-rest-api".</p>
  
  <p>What am I doing wrong?</p>