Michael Osofsky
Michael Osofsky

Reputation: 13175

Error "sast job: chosen stage does not exist; available stages are" for gitlab Static Application Security Testing

I tried following these fairly simple instructions for integrating Static Application Security Testing (SAST) into my Android CI/CD pipeline on Gitlab. However, I got the following error when using the CI lint tool:

sast job: chosen stage does not exist; available stages are .pre, stg_build, stg_test, .post

Here is the simplest version of my .gitlab-ci.yml that reproduces the error:

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"

stages:
  - stg_build
  - stg_test

I found a similar error in GitLab: chosen stage does not exist but that was about trying to use an environment variable as a stage name.

How do I prevent this error and get SAST working for my merge requests on Gitlab?

Upvotes: 3

Views: 12304

Answers (1)

Michael Osofsky
Michael Osofsky

Reputation: 13175

The problem is the Security/SAST.gitlab-ci.yml template expects there to be a stage named test but the test stage in .gitlab-ci.yml was renamed "stg_test".

I was able to find two ways to satisfy the CI Lint tool:

  1. Rename "stg_test" to "test"
  2. Configure the sast script to run during "stg_test" but adding the following to .gitlab-ci.yml:
sast:
  stage: stg_test

Sources:

  1. gitlab developer community
  2. Getting error message sast job: stage parameter should be [some stage name here]

Upvotes: 7

Related Questions