Loading .gitlab-ci.yml +45 −38 Original line number Diff line number Diff line workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - when: always #workflow: # rules: # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS # when: never # - when: always include: # include the component located in the current project from the current SHA - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/my-component@$CI_COMMIT_SHA inputs: job_name: "component job of my-component" stage: build #include: # # include the component located in the current project from the current SHA # - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/my-component@$CI_COMMIT_SHA # inputs: # job_name: "component job of my-component" # stage: build stages: - build - test - release # - test # - release print: stage: build tags: - shell script: - echo "testing..." ensure-job-added: stage: test image: badouralix/curl-jq rules: # project must be public for `curl` to access the API; using `CI_JOB_TOKEN` is insufficient! - if: $CI_PROJECT_VISIBILITY != "public" when: never - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - when: always script: | url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" curl --fail --show-error --silent "$url" | jq --exit-status 'map(select(.name | contains("component job of my-component"))) | length >= 1' #ensure-job-added: # stage: test # image: badouralix/curl-jq # rules: # # project must be public for `curl` to access the API; using `CI_JOB_TOKEN` is insufficient! # - if: $CI_PROJECT_VISIBILITY != "public" # when: never # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS # when: never # - when: always # script: | # url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" # curl --fail --show-error --silent "$url" | # jq --exit-status 'map(select(.name | contains("component job of my-component"))) | length >= 1' create-release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest rules: - if: $CI_COMMIT_TAG script: echo "Creating release $CI_COMMIT_TAG" release: tag_name: $CI_COMMIT_TAG description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH" #create-release: # stage: release # image: registry.gitlab.com/gitlab-org/release-cli:latest # rules: # - if: $CI_COMMIT_TAG # script: echo "Creating release $CI_COMMIT_TAG" # release: # tag_name: $CI_COMMIT_TAG # description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH" Loading
.gitlab-ci.yml +45 −38 Original line number Diff line number Diff line workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - when: always #workflow: # rules: # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS # when: never # - when: always include: # include the component located in the current project from the current SHA - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/my-component@$CI_COMMIT_SHA inputs: job_name: "component job of my-component" stage: build #include: # # include the component located in the current project from the current SHA # - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/my-component@$CI_COMMIT_SHA # inputs: # job_name: "component job of my-component" # stage: build stages: - build - test - release # - test # - release print: stage: build tags: - shell script: - echo "testing..." ensure-job-added: stage: test image: badouralix/curl-jq rules: # project must be public for `curl` to access the API; using `CI_JOB_TOKEN` is insufficient! - if: $CI_PROJECT_VISIBILITY != "public" when: never - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - when: always script: | url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" curl --fail --show-error --silent "$url" | jq --exit-status 'map(select(.name | contains("component job of my-component"))) | length >= 1' #ensure-job-added: # stage: test # image: badouralix/curl-jq # rules: # # project must be public for `curl` to access the API; using `CI_JOB_TOKEN` is insufficient! # - if: $CI_PROJECT_VISIBILITY != "public" # when: never # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS # when: never # - when: always # script: | # url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs" # curl --fail --show-error --silent "$url" | # jq --exit-status 'map(select(.name | contains("component job of my-component"))) | length >= 1' create-release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest rules: - if: $CI_COMMIT_TAG script: echo "Creating release $CI_COMMIT_TAG" release: tag_name: $CI_COMMIT_TAG description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH" #create-release: # stage: release # image: registry.gitlab.com/gitlab-org/release-cli:latest # rules: # - if: $CI_COMMIT_TAG # script: echo "Creating release $CI_COMMIT_TAG" # release: # tag_name: $CI_COMMIT_TAG # description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH"