Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force GitLab to run a complete pipeline before starting a new one?

Tags:

gitlab

I have one runner associated with my project to avoid concurrent build. GitLab to process the complete pipeline before start a new one?

concurrent is set to = 1 (config file of the runner)

before_script:
  - echo %CI_COMMIT_SHA%
  - echo %CI_PROJECT_DIR%

stages:
  - createPBLs
  - build
  - package


create PBLs:
  stage: createPBLs
  script: 
    - md "C:\HierBauen\%CI_COMMIT_SHA%\"
    - xcopy /y /s "C:/Bauen" "C:/HierBauen/%CI_COMMIT_SHA%"
    - xcopy /y /s "%CI_PROJECT_DIR%" "C:\HierBauen\%CI_COMMIT_SHA%"
    - cd "C:\HierBauen\%CI_COMMIT_SHA%"
    - ./run_orcascript.cmd
  only:
  - tags
  - master

build:
  stage: build
  script:
  - cd "C:\HierBauen\%CI_COMMIT_SHA%"
  - ./run_pbc.cmd
  only:
  - tags
  except:
  - master

build_master:
  stage: build
  script:
  - cd "C:\HierBauen\%CI_COMMIT_SHA%"
  - ./run_pbcm.cmd
  only:
  - master

package:
  stage: package
  script:
  - cd "C:\HierBauen\%CI_COMMIT_SHA%"
  - ./cpfiles.cmd
  artifacts:
    expire_in: 1 week
    paths:
      - GitLab-Build
    name: "%CI_COMMIT_REF_NAME%"
  only:
  - tags
  - master

Unfortunately, the earlier started pipeline is disturbed by a new started pipeline. As a result, the build is flawed at the end ...

EDIT new config file:

before_script:
  - echo %CI_BUILD_REF%
  - echo %CI_PROJECT_DIR%
  - xcopy /y /s "C:/Bauen" "%CI_PROJECT_DIR%"

stages:
  - createPBLs
  - build
  - package


create PBLs:
  stage: createPBLs
  script: 
    - ./run_orcascript.cmd
  only:
  - tags
  - master


build:
  stage: build
  script:
  - ./run_pbc.cmd
  only:
  - tags
  except:
  - master


build_master:
  stage: build
  script:
  - ./run_pbcm.cmd



  only:
  - master

package:
  stage: package
  script:
  - ./cpfiles.cmd
  artifacts:
    expire_in: 1 week
    name: "%CI_COMMIT_REF_NAME%"
    paths:
      - GitLab-Build
  only:
  - tags
  - master
like image 509
Hendouz Avatar asked Mar 28 '18 13:03

Hendouz


People also ask

How do you're run entire pipeline on GitLab?

Go to your Settings > CI/CD under Triggers to add a new trigger. The Add trigger button creates a new token which you can then use to trigger a rerun of this particular project's pipeline. Every new trigger you create, gets assigned a different token which you can then use inside your scripts or . gitlab-ci.

Can a GitLab project have multiple pipelines?

GitLab CI/CD is a powerful continuous integration tool that works not only per project, but also across projects with multi-project pipelines. Multi-project pipelines are useful for larger products that require cross-project inter-dependencies, such as those adopting a microservices architecture.


1 Answers

Currently there is no way for this, and there is an open issue at the moment on GitLab.

What you can do instead is to add limit = 1 in your gitlab-runner config.toml file, which would enforce the gitlab-runner to only accept one job at a time.

I see that you are not passing artifacts between your stages, but if your build stage, depended on anything in the createPBLs stage, you can use a combination ofartifacts and dependencies to pass data between stages.


For example:

before_script:
  - echo %CI_COMMIT_SHA%
  - echo %CI_PROJECT_DIR%

stages:
  - createPBLs
  - build
  - package


create PBLs:
  stage: createPBLs
  script: 
    - md "C:\HierBauen\%CI_COMMIT_SHA%\"
    - xcopy /y /s "C:/Bauen" "C:/HierBauen/%CI_COMMIT_SHA%"
    - xcopy /y /s "%CI_PROJECT_DIR%" "C:\HierBauen\%CI_COMMIT_SHA%"
    - cd "C:\HierBauen\%CI_COMMIT_SHA%"
    - ./run_orcascript.cmd
  artifacts:
    name: createPBLS_%CI_COMMIT_SHA%
    untracked: true
    expire_in: 1 day
  only:
  - tags
  - master

build:
  stage: build
  script:
  - cd "C:\HierBauen\%CI_COMMIT_SHA%"
  - ./run_pbc.cmd
  dependencies:
  - createPBLs
  artifacts:
    name: build_%CI_COMMIT_SHA%
    untracked: true
    expire_in: 1 day
  only:
  - tags
  except:
  - master

build_master:
  stage: build
  script:
  - cd "C:\HierBauen\%CI_COMMIT_SHA%"
  - ./run_pbcm.cmd
  dependencies:
  - createPBLs
  artifacts:
    name: build_%CI_COMMIT_SHA%
    untracked: true
    expire_in: 1 day
  only:
  - master

package:
  stage: package
  script:
  - cd "C:\HierBauen\%CI_COMMIT_SHA%"
  - ./cpfiles.cmd
  dependencies:
  - build_master
  artifacts:
    expire_in: 1 week
    paths:
      - GitLab-Build
    name: "%CI_COMMIT_REF_NAME%"
  only:
  - tags
  - master
like image 99
Rekovni Avatar answered Sep 29 '22 07:09

Rekovni