Skip to content

Draft: External jobs PoC

Tiger Watson requested to merge external-jobs-poc into master

What does this MR do and why?

Not to be merged. Spike for #427389 (closed).

Screenshots or screen recordings

Screenshot_2023-10-11_at_3.06.29_pm

Screenshot_2023-10-11_at_3.07.04_pm

How to set up and validate locally

  1. Create a personal access token
  2. Create a new project, and add the following .gitlab-ci.yml:
    stages:
      - build
      - sync
      - report
    
    build:
      stage: build
      script:
        - echo 'build'
    
    sync:
      stage: sync
      external: true
      environment: production
      timeout: 10m
    
    report:
      stage: report
      script:
        - echo 'report'
  3. Make a note of the ID of your project, and the SHA for the commit you just created
  4. View the created pipeline, and wait until the build job has finished (should be almost instant)
  5. Observe the sync job "starts", but is not actually running via runner
  6. From a terminal, execute the following, replacing TOKEN, PROJECT_ID, BRANCH and SHA with the relevant values:
    curl --request POST \
         --header "PRIVATE-TOKEN: <TOKEN>" \
         "https://gdk.test:3443/api/v4/projects/<PROJECT_ID>/pipeline_callback?ref=<BRANCH>&sha=<SHA>&job_name=sync&job_status=success"
  7. Watch the pipeline page, and observe the sync job completes successfully, the report job starts and completes, and the pipeline succeeds
  8. [Optional] Start another pipeline, and execute the same curl command, this time with job_status=failed. The pipeline will fail as expected
  9. [Optional] Adjust the timeout in the external job definition to 1m. The pipeline will fail by itself when the timeout is reached

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Tiger Watson

Merge request reports