Venu Chitta
Venu Chitta

Reputation: 300

Gitlab CI passing dependencies among jobs

I am new to GitLab CI. I have a project where I have a Gitlab project and I have jobs generate, detectchanges, compile. The requirement is generate job generates some go files from templates, detectchanges need to act on same codebase including all the changes that generate job generates (like tempCreateTest/myfile.txt in example below) and compile again acts on same codebase and chanfes as genetate job acts upon. My problems are: 1. I couldnt see the changes that generate job generates even using dependencies. For example tempCreateTest/myfile.txt is not being seen by detect_changes and compile jobs 2. When I use dependency where exactly gitlab downloads the artifacts?

Can someone please answer this?

Here is my sample .gitlab-ci.yml

image: golang:1.11

stages:
  - generate
  - detect_changes
  - build

before_script:
  # Setup environment
  - export GOPATH=/builds/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/go
  - export GO_PROJECT_PATH=$GOPATH/src/gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
  - export RAW_REPO_PATH=/builds/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/.
  - mkdir -p $GO_PROJECT_PATH
  - cp -r $RAW_REPO_PATH/. $GO_PROJECT_PATH
  - cd $GOPATH
  - export GO111MODULE=on
  - cd $GO_PROJECT_PATH
  - source ci.sh # This has functions that jobs use

generate_ci:
  stage: generate
  script:
    - generate_ci_script
    - mkdir tempCreateTest/ . 
    - echo "Some text here." > tempCreateTest/myfile.txt # Stages after generate should see the changes
  artifacts:
    untracked: true

detect_changes_ci:
  stage: detect_changes
  script:
    - detect_changes_ci_script 
  dependencies:
    - generate_ci

compile_ci:
  stage: detect_changes
  script:
    - compile_ci_script
  dependencies:
    - generate_ci

Upvotes: 3

Views: 6512

Answers (1)

djuarezg
djuarezg

Reputation: 2541

You can use CI artifacts or caching to accomplish that. Please take a look at the examples from the previous links.

Upvotes: 2

Related Questions