Search code examples
gitlabgitlab-cigitlab-api

Get artifacts of included gitlab template


I’d like to use the artifacts created by the Security/SAST.gitlab-ci.yml template in my final pipeline stage (reporting).

How can I modify the Security/SAST.gitlab-ci.yml template to store the artifacts somewhere in my project dir? I tried to define the following for this template, but this is not working:

artifacts:
  paths:
    - binaries/

I’d be happy for every kind of support.

Thank you


Solution

  • Solution

    Your parameters need to be updated. Since SAST.gitlab-ci.yml cannot be updated directly, you need to either override one of the blocks from your gitlab-ci.yml which includes the file, or define and include your custom SAST.gitlab-ci.yml. It seems like you can get away with simply overriding the sast block. Specifically, override the artifacts -> reports -> sast parameter.

    Example

    sast:
      stage: test
      artifacts:
        reports:
          sast: gl-sast-report.json
    

    You also need to ensure the stages and build step is something resembling

    
    stages:
      - build
      - test
    
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    build:
      stage: build
      script:
        - ...
      artifacts:
        paths:
          - binaries/
    
    

    References

    Gitlab SAST: https://docs.gitlab.com/ee/user/application_security/sast/