How to avoid clone for a next stage?

Hi,

I run successfully a gitlab-ci instance with 2 runners, a debian and a Win10.
I use CMake to configure a cross-platform c++ project, so I have a cmake step to generate the build environment (ie Makefile or Visual Studio project).
I also generate a latex documentation (which uses cmake-generated files)
I thought I would be able to represent these steps through “stages” :
stages:

  • configure
  • documentation

The “configure” stage passed, very fine, on both runner. However, the documentation stage starts with a suppression of the previous clone and re-clone the repo. Is it possible to avoid the initial clone when a stage begins? And use the previous stage’s outputs ?

For instance, I will have also a build step - in terms of ‘make’ -. So basically, I would have to show the result passed/failed of the cmake stage and the build stage, with the build stage using the cmake-generated files from the cmake stage.

Thanks a lot!

Not precisely what you’re after as this wont prevent the re-cloning but may work for you as will allow you to use output from previous stages.

If you have a build step you can configure artifacts in the build step then specify dependencies on your documentation job e.g

build_step:
    artifacts:
        name: "${CI_BUILD_NAME}"
        paths:
            - some/path/with/your/output

documentation_step
    dependencies:
        - build_step

If you dont need the artifacts to be lying around after the documentation you can specify expire_in: 1 hour to the artifacts section of your build_job. You may be able to use cache instead of artifacts.

Thanks a lot alasdair,

I tried something with cache but I found a zip file in the output path, so I thought it was not the right tool. I will give a try with the artifacts item, as it makes sense.

Besides, I managed to do something else (before your answer). Let’s forget about documentation. I have a “configure” step which generates a Makefile or a VisualStudio solution depending on the platform. Then I have a usual “build” step in the c/c++ meaning.
To summarize and stick with the initial topic, I want my “configure” step to clone the repo and generate the dev environment files. Then I want the “build” step to use the “configure” outputs.
Basically, I use the CI_PROJECT_DIR variable in order to find the cloned project folder. Thus I can launch an out-of-source build in predefined folder and work with it. Here is my yaml :

stages:

  • configure #cmake step
  • build
  • test

configure-linux:
script:
- echo $CI_PROJET_DIR
- rm -rf ~/build
- mkdir ~/build
- cd ~/build
- cmake $CI_PROJECT_DIR
stage: configure
tags:
- linux

make-linux:
script:
- cd ~/build
- make
stage: build
tags:
- linux

test-linux:
script:
- cd ~/build
- ctest
stage: test
tags:
- linux

What you told me about artifacts opened my mind, and it seems like my rm/mkdir script instruction will be useless. Obviously, it won’t prevent the cloning process.

No problem emorej.

Only really started playing about with artifacts myself for a php project using bower / grunt. One of the advantages of artifacts is they can be downloadable if required.

Tweaking your yaml for artifacts could be something like:

stages:
    - configure #cmake step
    - build
    - test

configure-linux:
    # build dir will also be downloadable via the web interface until expiry
    artifacts:
        name: "${CI_BUILD_NAME}" # can add any other variables neeed
        expire_in: 1 hour # optional expiry
        paths:
            - build 
    script:
        - echo $CI_PROJET_DIR
        - mkdir -p build
        - cd build
        - cmake $CI_PROJECT_DIR
    stage: configure
    tags:
        - linux

make-linux:
    # reuse build dir from configure step
    dependencies:
        - configure-linux
    # create updated artifacts for using in test job
    artifacts:
        name: "${CI_BUILD_NAME}" # can add any other variables neeed
        expire_in: 1 hour # optional expiry
        paths:
            - build 
    script:
        - cd build
        - make
    stage: build
    tags:
        - linux

test-linux:
    # reuse build dir from make step
    dependencies:
        - make-linux
    script:
        - cd build
        - ctest
    stage: test
    tags:
        - linux

Hope this helps.