InfoGrab DocsInfoGrab Docs

GitLab Functions 예제

Google distroless 이미지를 활용한 GitLab Functions 예제를 설명합니다.

GitLab Functions 예제 # - Tier: Free, Premium, Ultimate - Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated # Status: Experiment 다음 예제는 ca-certificates 가 포함되어 있지만 패키지 매니저나 셸이 없는 Google distroless 이미지를 사용합니다. 신뢰할 수 있는 CA 루트 인증서가 설치된 이미지라면 어떤 이미지든 사용할 수 있습니다. 메시지 출력 # 후속 단계에서 사용할 메시지를 출력합니다. 전체 소스 코드는 echo 를 참조하세요. 함수 정의: spec: inputs: message: type: string default: "Hello World!" description: "The message to print to stdout" outputs: message: type: string --- exec: command: - ${{ func_dir }}/echo - --message - ${{ inputs.message }} - --output-file - ${{ output_file }} 사용법: my-job: image: gcr.io/distroless/static-debian12 run: - name: echo_hi func: registry.gitlab.com/gitlab-org/ci-cd/runner-tools/gitlab-functions-examples/echo:1 inputs: message: "Hi, ${{ vars.GITLAB_USER_NAME }}" - name: echo_repeat func: registry.gitlab.com/gitlab-org/ci-cd/runner-tools/gitlab-functions-examples/echo:1 inputs: message: "The echo_hi step said: ${{ steps.echo_hi.outputs.message }}" 출력: Running step name=echo_hi Hi, Zhang Wei Running step name=echo_repeat The echo_hi step said: Hi, Zhang Wei 랜덤 값 생성 # 후속 단계에서 사용할 랜덤 값을 생성합니다. 전체 소스 코드는 random 을 참조하세요. 함수 정의: spec: outputs: random_value: type: string --- exec: command: - ${{ func_dir }}/random - --output-file - ${{ output_file }} 사용법: my-job: image: gcr.io/distroless/static-debian12 run: - name: random func: registry.gitlab.com/gitlab-org/ci-cd/runner-tools/gitlab-functions-examples/random:1 - name: print_random func: registry.gitlab.com/