Score:0

how to share "build repository dir" between jobs in multiple gitlab runner configuration?

am flag
lee

I'm using a gitlab runner to deploy application -shared gitlab runner and concurrent count is 4

/etc/gitlab-runner/config.toml
        concurrent = 4
        check_interval = 0
        executor = shell

All jobs run in a different stage each other.

.gitlab-ci.yml

stages:
  - build-prod-stage
  - deploy-prod-stage

BUILD_PROD_JOB:
  stage: build-prod-stage
  variables:    
    GIT_CLEAN_FLAGS: none      
  script:
    - xxxxxx
    - xxxxx

DEPLOY_PROD_JOB:
  variables:
    GIT_CLEAN_FLAGS: none 
  stage: deploy-prod-stage
  script: 
    - xxxxxx
    - xxxxxx*

Mostly, BUILD_PROD_JOB and DEPLOY_PROD_JOB run in a same build directory. But, sometimes they use a different directory each other

gitlab-runner log

BUILD_PROD_JOB Fetching changes with git depth set to 50... Initialized empty Git repository in /xxxx/gitlab-runner/builds/(gitlab-runner name)/1/(respository name)/.git/ .....

DEPLOY_PROD_JOB Fetching changes with git depth set to 50... Initialized empty Git repository in /xxxx/gitlab-runner/builds/(gitlab-runner name)/0/(respository name)/.git/ ....

I guessed why this things happen.

  • BUILD_PROD_JOB started to run while other job is running. so, CI_CONCURRENT_ID is 1
  • DEPLOY_PROD_JOB started to run after other jobs is completed, so CI_CONCURRENT_ID is 0

In this case, can I force "DEPLO_PROD_JOB" runs in same build_dir of "BUILD_PROD_JOB"?

  • BUILD_PRODJOB --> /xxxx/gitlab-runner/builds/(gitlab-runner name)/1/(respository name)/.git/
  • DEPLOY_PRODJOB --> /xxxx/gitlab-runner/builds/(gitlab-runner name)/1/(respository name)/.git/
Score:0
ug flag

You'll need to use artifacts and dependencies to pass data between jobs:

stages:
  - build-prod-stage
  - deploy-prod-stage

BUILD_PROD_JOB:
  stage: build-prod-stage
  variables:    
    GIT_CLEAN_FLAGS: none      
  script:
    - xxxxxx
    - xxxxx
  artifacts:
    paths:
    - path-to-the-folder-you-want-to-share-between-jobs

DEPLOY_PROD_JOB:
  variables:
    GIT_CLEAN_FLAGS: none 
  stage: deploy-prod-stage
  script: 
    - xxxxxx
    - xxxxxx*
  needs:
    - job: BUILD_PROD_JOB
      artifacts: true
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.