0
votes

I'm trying to use Gitlab CI to build C code in a pipeline stage and to execute it in the following one.

The problem is that the exection test stage doesn't find the binary file I'd like not to have to rebuild at every stage in order to use less CPU during the pipeline so I though that cache should be the way to go.

Here is my .gitlab-ci.yml file :

stages: 
  - build
  - test
  - deploy

job:build:
  stage: build 
  before_script:
    - pwd
  script: 
    - mkdir bin/
    - gcc -o bin/main.exe *.c
  cache:
    key: build-cache
    paths:
      - bin/
  after_script:
    - ls -R

job:test:unit:
  stage: test 
  script: echo 'unit tests'

job:test:functional:
  stage: test 
  before_script:
    - pwd
    - ls -R
  script: 
    - echo 'functionnal test'
    - cd bin ; ./main.exe

job:deploy:
  stage: deploy 
  script: echo 'Deploy stage'
1

1 Answers

0
votes

So i figured out that i have to use artifacts :

Here is my code :

stages: 
  - build
  - test
  - deploy

job:build:
  stage: build 
  before_script:
    - pwd
  script: 
    - mkdir bin/
    - gcc -o bin/main.exe *.c
  artifacts:
   expire_in: 1 day
   paths:
      - bin/main.exe
  after_script:
    - ls -R

job:test:unit:
  stage: test 
  script: echo 'unit tests'

job:test:functional:
  stage: test 
  before_script:
    - pwd
    - ls -R
  script: 
    - echo 'functionnal test'
    - cd bin ; ./main.exe
  dependencies:
   - job:build

job:deploy:
  stage: deploy 
  script: echo 'Deploy stage'