Skip to content

Search in repositories

Go to Automation

View in GitLab

Description

This playbook executes a series of tasks to search for a regular expression in GitLab repositories. It creates the directory /opt/gitlabclone and copies a script sync_gitlabclone.sh to this directory, along with logrotate and cron configurations, if the setup variable is true.

The playbook synchronizes the repositories by running the script sync_gitlabclone.sh and displays the result if the sync variable is true. It then searches for the regular expression in the repositories using the grep command and displays the results, unless the find_filenames variable is true. In that case, it searches for filenames that match the regular expression and displays those results.

Credentials

  • Gitlab CI API token) (sys_gitlabclone)

Input

Variable Description
regex The (extended) grep pattern to search for. Can be a word or a regular expression (case-insensitive). Note that only the master or main branches are scanned. Check grep man for details.
find_filenames Set to true to search for filenames instead of matches within the files/code themselves.
sync If set to true, all GitLab repositories will be synchronized before searching (takes about 30 seconds). Repositories are synchronized automatically every 3 hours.
setup Set to true only if sync_gitlabclone.sh.j2 have been updated in GitLab.

Output

Variable Description
search_output.stdout_lines JSON array with found results

Dependencies