How to create a pipeline job for an external runner?

Hello gitlab community :wave:

I have a pipeline where I build expo.dev applications, one way to build an app is to use a service ‘EAS’ that is basically a runner that runs on their premises.

Today, I’m launching the build using a command within a job, and that job is stalled doing nothing while polling for a result from the build job ran at EAS. Basically it looks like this:

stages:
 - build
 - deploy

.build-base: &build-base
  <<: *setup_expo
  image: node:14-alpine
  cache:
    - key:
        files:
            - yarn.lock
      paths:
        - node_modules

build-native-production:
  <<: *build-base
  stage: build
  before_script:
    - apk add --no-cache bash git
  script:
    - yarn --frozen-lockfile --prefer-offline
    - yarn run eas build -p all --non-interactive --profile="production"

And here’s the build log:

All credentials are ready to build @zeloce/zaas-driver (app.zeloce.driver)
- Uploading to EAS Build (0 / 3.8 MB)
✔ Uploaded to EAS  Learn more: https://expo.fyi/eas-build-archive
🤖 Android build details: https://expo.dev/accounts/zeloce/builds/69ddd2d8-8e63-463a-9c81-f41a7d6c90cb
🍎 iOS build details: https://expo.dev/accounts/zeloce/builds/fa2a32be-e6cb-4631-b70d-2a82d4e7c700
Waiting for builds to complete. You can press Ctrl+C to exit.
✔ All builds have finished
🤖 Android app:
https://expo.dev/artifacts/eas/e5e4eU99vLkPPBPpkWY5Zi.aab
🍎 iOS app:
https://expo.dev/artifacts/eas/wTGJRcRiJZWPrSFRKU6ZMA.ipa
Done in 3081.87s.

So it finishes with a total duration of 54 minutes 11 seconds.

So I end up having a job doing nothing for almost an hour running on the CI minutes.
I could launch the job and follow up on the other application, but I’d rather keep everything from within the pipeline.

I saw that some integrations (like https://chromatic.io) does exactly that:

  • it launches a job on another service,
  • that job callbacks gitlab.com,
  • it updates the pipeline, adding an external job,
  • when you click on it it opens the webpage of that other job, and
  • updates the status of that external job with a success or failure when it’s done.

I tried to look the documentation of gitlab’s API and some other documentation elsewhere, I asked around on IRC or gitter for pointers, but no luck.

Is there any doc/tutorial/api doc that one could point to me where I can create/update an external job with the environment from within a gitlab pipeline’s job?

Thank you :pray:

So I found this documentation that might be what I’m looking for… :thinking:

It was, but now I’m having another yet related issue, that API endpoint does not work with the $CI_JOB_TOKEN, but it does with a personal access token.

Though, I’d like to callback the gitlab API to push new statuses from expo’s runners using the above API without having to permanently store a token that gives full access to the API through my account… And I believe the commit status API should be accessible using $CI_JOB_TOKEN.

But what bugs me is that people at chromatic.io did succeed to implement that feature without getting any access token from their users, so there should be a way to make that API accessible.