Using “run_scan.bat” to Configure the CI/CD Pipeline
The following procedure uses the run_scan.bat file to configure the CI/CD pipeline to run a generic scan-agent plugin scan as part of your application build.
To use “run_scan.bat” to configure the CD/CI pipeline to run a generic scan-agent plugin scan, do the following:
-
Download and extract the contents of the
CodeInsightversionPlugins.zipfile, as described in the previous section, Downloading Plugins. -
Locate the
generic-plugin-binaryfolder (in thecode-insight-agent-sdk-generic-pluginfolder), and copy it to theGitLab-runnerfolder (that is, your GitLab installation folder). -
Under the
GitLab-Runnerfolder, create an output folder. For example, create a folder namedoutput.GitLab Runner uses this folder to store logs and codebase information as part of the background process during the build.
-
Locate the
run_scan.batfile in theGitlab-Runner\generic-plugin-binaryfolder. -
Open the file in an editor, and update the following properties to match your environment:
-
For the SET_ROOT_PATH property, provide the path for the output folder created in Step 4. For example:
SET ROOT_PATH=D:\GitLab-Runner\output(Adjust the path as needed to match your GitLab Runner installation.)
-
For the cd command (in the next line after the SET_ROOT_PATH property), provide the location of the
run_scan.batfile in GitLab Runner. For example:cd D:\GitLab-Runner\generic-plugin-binary(Adjust the path as needed to match your GitLab Runner installation.)
infoIf the “cd” command is currently a comment, be sure to uncomment the line.
-
-
Save the
run_scan.batfile. -
Restart GitLab Runner using the following command:
.\gitlab-runner.exe restart -
Locate the
gitlab.ci.ymlfile for the repository containing the code you want to scan, and open this file in an editor. -
Update this file with information pertaining to the plugin scan.
-
Add the following information defining the scan job:
codeinsight_scan:
stage: test
only:
- main
tags:
- <tag_for_your_GitLab-Runner>
script:
- cmd /Q /C <path\to\generic-plugin-binary\run_scan.bat> "$CODEINSIGHT_PROJECT" "$CODEINSIGHT_SERVER" "$AUTH_TOKEN" <codebase_folder_paths> <alias> -
In the
scriptsection, replace the following with information required for the plugin scan:-
<path\to\generic-plugin-binary\run_scan.bat>—The path of the
run_scan.batfile integrated with GitLab Runner, as in the example:D:\GitLab-Runner\generic-plugin-binary\run_scan.bat -
<Codebase_folder_paths>—The path of the specific codebase folder to be scanned. Separate multiple folder paths with commas. These folders must be located on the local machine.
-
<alias>—A user-defined name for the scan-agent plugin, such as
Eportal_Remote on abc.com. The alias is simply used to represent the “container” (scan root) under which all the scanned files will be listed in the API output and in the file tree in the Analysis Workbench. The name must be unique within the Code Insight project.
noteDo nothing with the variables
$CODEINSIGHT_PROJECT,$CODEINSIGHT_SERVER, and$AUTH_TOKENin thescriptsection. These variables will be defined in the pipeline-schedule setup for the plugin scan (described in Step 11) and passed to the command listed. -
-
-
Save the
gitlab.ci.ymlfile. -
When configuring the CI/CD pipeline schedule in the UI to run a Code Insight plugin scan, define the variables required for the scan:
-
Navigate to the Variables section in the UI for the pipeline schedule.
-
Select the specific variable from the dropdown and provide its value, as described in this list:
-
CODEINSIGHT_SERVER—The URL of the Code Insight Core Server (for example,
http://1.1.1.1:8888/codeinsight). -
CODEINSIGHT_PROJECT—The project you created in Code Insight to store the scan results (for example,
"gitlabProject2"). -
AUTH_TOKEN—Your JSON Web Token (JWT) used to authorize user access to the Code Insight functionality, as in
"eyJhbGciOiJIUzUxMiJ9...."(not showing the complete token).Generate this token using the Code Insight Web UI and then copy and paste it in this field. For more information, see Providing an Authorization Token.
noteDo not precede the JWT with the term “Bearer”, as it is already provided in the
run_scan.batfile. -
-
Save the pipeline schedule once it is properly set up.
-
When triggered, the job for the plugin scan should run successfully.