[gitlab] 여러 gitlab 파이프 라인에 걸쳐 작업 그룹을 “잠글”수 있습니까?

단일 외부 리소스 (서버)로 작업하는 여러 작업이 있습니다. 첫 번째 작업은 앱을 환경에 배포하고, 두 번째는이 환경에서 테스트를 실행하고, 세 번째는이 환경에서 통합 테스트를 실행합니다.

리소스 그룹 옵션 이 있다는 것을 알고 있습니다. 그러나 작업 만 잠급니다. 두 개의 파이프 라인을 동시에 실행하면 내가 실행해야 job1, job2, job3두 번째 파이프 라인 시작할 수 있습니다 – 첫번째 파이프 라인과 첫 번째 파이프 라인 출시 리소스에서 jobs1-3. 이것을 달성 할 수있는 방법이 있습니까? 파이프 라인에는 다른 작업이 있습니다. 동시에 작업해야합니다.



답변

작업을위한 전용 러너를 설정하십시오 1-3.

  1. 고유 태그 (예 : ‘jobs-1-2-3’)를 사용하여 concurrent1새 러너설정하고 옵션 을로 설정하십시오 .

  2. 해당 작업에 고유 태그 (예 : ‘jobs-1-2-3’)를 추가하십시오.

    job1:
      tags:
        - jobs-1-2-3
    job2:
      tags:
        - jobs-1-2-3
    job3:
      tags:
        - jobs-1-2-3
    

IMHO 이것은 노력이 적고 신뢰성이 높습니다.


답변

needsand resource_group키워드와 gitlab API를 통해 구현할 수 있다고 생각합니다 .

모든 작업은 자신이 속한 파이프 라인 ID를받습니다 predefined-variable. gitlab API를 사용하면 파이프 라인에서 다른 작업의 상태를 볼 수 있습니다. 이 상태 needsresource_group키워드를 사용할 수 있다면 원하는 것을 달성 할 수 있다고 생각합니다. 자세한 내용은 아래 코드 설명 및 주석을 참조하십시오.

stages:
  - ready
  - build

job1:
  stage: build
  needs: [starting_signal]
  script:
    - sleep 10 && echo "job1"
job2:
  stage: build
  needs: [starting_signal]
  script:
    - sleep 20 && echo "job2"
job3:
  stage: build
  needs: [starting_signal]
  script:
    - sleep 30 && echo "job3"

starting_signal:
  stage: ready
  script:
    - # TODO: You need to implement it using the GitLab API.
    - # The starting condition for "job1-3" is
    - # that this `starting_signal` job finished successfully.
    - # And the condition that ends with the success of this job
    - # is that `traffic_light` becomes running.

traffic_light:
  stage: ready
  resource_group: traffic_light
  script:
    - # TODO: You need to implement it using the GitLab API.
    - # The end condition for `traffic_light` is
    - # the end of job1-3 execution.
    - # In other words, this job must be checked and waited
    - # through gitlab api until job 1,2,3 is finished.
    - # Since this job locks the execution of a `traffic_light` job
    - # in another pipeline, the `starting_signal` job in another
    - # pipeline does not succeed.

(나는 그것을 직접 테스트하지 않았 으므로이 방법을 검토해야합니다.)

추천 :


답변