Commit 384cbe60 authored by GitLab's avatar GitLab Committed by Philipp Matthias Hahn
Browse files

Initialized from 'GitLab CI/CD components' project template

Template repository: https://gitlab.com/gitlab-org/project-templates/gitlab-component-template
Commit SHA: b8b0a4a1821acf43f82912e4bd00a38cea90aa62
parents
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+44 −0
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

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

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"

LICENCE

0 → 100644
+21 −0
Original line number Diff line number Diff line
MIT License

Copyright (c) <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

README.md

0 → 100644
+52 −0
Original line number Diff line number Diff line
# Gitlab component template

<!--
Update this readme with your component details. Replace content in `< >` with your project information.
For more information:

- How to create a CI/CD component: https://docs.gitlab.com/ee/ci/components/#write-a-component
- How to write a clear README.md file: https://docs.gitlab.com/ee/ci/components/#write-a-clear-readmemd
- CI/CD Component security best practices: https://docs.gitlab.com/ee/ci/components/#cicd-component-security-best-practices
-->

<!-- Uncomment and update the following link to display a release badge: https://docs.gitlab.com/ee/user/project/badges.html#latest-release-badges -->
<!-- [![Latest Release](https://gitlab.com/<your project path>/-/badges/release.svg)](https://gitlab.com/<your project path>/-/releases) -->

## Components

### `<Component-name>`

Use this component to `<component-description>`.

To add this component to your CI/CD pipeline, add the following include entry to your
project's CI/CD configuration:

```yaml
include:
  - component: https://gitlab.com/<your project path>/<name of your template>@<tag>
```

Where `<tag>` is the release tag you want to use ([releases list](https://gitlab.com/<your-project-path>/-/releases)).

## Inputs

The template contains some optional [inputs](https://docs.gitlab.com/ee/ci/yaml/inputs.html):

<!-- Add or update rows if you change the inputs in the template -->

| Input      | Default value    | Description |
|------------|------------------|-------------|
| `job_name` | `job-template`   | The job name. |
| `image`    | `busybox:latest` | The container image to use to run the job. |
| `stage`    | `test`           | The stage name for the job. |

## Documentation

This project includes a MVC structure to help you get started with [Gitlab CI/CD components](https://docs.gitlab.com/ee/ci/components/).
The template provides the basic file structure to create your own single component.
This project should be public, or one of the jobs in the project's pipeline won't work.

## Licence

The licence can be changed. By default this project has the [MIT Licence](./LICENCE).
<!-- You should update the year and name in the license file. -->
+23 −0
Original line number Diff line number Diff line
spec:
  inputs:
    # These are examples of inputs.
    job_name:
      default: job-template
    image:
      default: busybox:latest
    stage:
      default: test

---
# This is an example of a job using inputs
# use variables with this syntax : $[[ inputs.xxx ]]
$[[ inputs.job_name ]]:
  image: $[[ inputs.image ]]
  stage: $[[ inputs.stage ]]
  script:
    - echo "Starting job $[[ inputs.job_name ]]"
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - when: always