secret_detection fails when included along side Android.gitlab-ci.yml

Summary

When AutoDevops is used to combine Android and Secret detection, secret_detection fails with:

/bin/sh: eval: line 125: apt-get: not found
$ apt-get --quiet update --yes
Uploading artifacts for failed job 00:01
Uploading artifacts...

(example job)

This is because

  • the before_script from the Android template is applied to all jobs
  • the step to execute apt-get fails because it is missing from the image specified for secret detection
  • the whole job fails

Or more specifically, because secret detection should not run Android's before_script

GitLab team members can read more in the ticket.

Workaround

Over-ride before_script for the secret_detection job in .gitlab-ci.yml

secret_detection:
  before_script:
    - echo "hello world"

Steps to reproduce

  1. Any project will work, but for an Android project try hidroh/materialistic which is referred to in our blog posts.

  2. Specify .gitlab-ci.yml. The Android jobs are not required to reproduce this.

include:
  - template: Android.gitlab-ci.yml
  - template: Security/Secret-Detection.gitlab-ci.yml

lintDebug:
  when: manual

assembleDebug:
  when: manual

debugTests:
  when: manual
  1. Review the log for the secret_detection job

Example Project

https://gitlab.com/bprescott-support/testing/zd232955-android-autodevops

What is the current bug behavior?

secret_detection job fails

What is the expected correct behavior?

secret_detection job works

With the over-ride it runs.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

14.3.0-pre 3552ee8fc07

Possible fixes

Edited by 🤖 GitLab Bot 🤖