1

I was thinking about a pipeline with the following steps:

  1. Install image dependencies (such as java, node, yarn and openssl)
  2. Install node packages needed for the build
  3. Install PMD
  4. Do a code Analysis
  5. Build
  6. Deploy
  7. Run tests on the server
  8. Clean up

But the issue here is that I require the tools installed on steps 1 and 2 for the rest of the build. There's a package that is used to run steps 5 to 7, for example, and OpenSSL is required to decrypt a server key in the repository (so GitLab can connect to the server).

I can't seem to find a way to persist Yarn's install through different stages. When the pipeline moves from stage 1 to stage 2, it will use yarn commands and will fail with the 127 error code (command not found), like this:

$ yarn global add sfdx-cli
/bin/sh: eval: line 81: yarn: not found

ERROR: Job failed: exit code 127

Is it possible to persist the "environment setup" through all the stages? Can artifacts be used for this? If so, will I need to setup the commands for every stage? For example: Yarn might be installed in a folder which will be cached, but I need to point the 'yarn' command to the correct binary, right?

1

We install things in the before_script section of the .gitlab-ci.yml that way on every run of the runner we know what packages exist for each stage.

Not the answer you're looking for? Browse other questions tagged or ask your own question.