Skip to main content

Setting Up the Code Insight Jenkins Scan-Agent Plugin

The following procedure describes how to configure the Jenkins scan-agent plugin.

  1. Extract the Jenkins scan-agent plugin from the CodeInsightversionPlugins.zip file. For more information, see Downloading Plugins.

  2. Access your Jenkins server instance and navigate to Manage Jenkins -> Manage Plugins -> Advanced tab -> Upload Plugin.

  3. Browse to the code-insight-scan-plugin.hpi file, and click Upload.

  4. Restart the Jenkins server after installing the plugin.

  5. Open an existing Jenkins project, or use these steps to create a new Jenkins project:

    1. Click New Item.
    2. Enter a name.
    3. Select a project type.
    4. Click OK.
  6. To configure the project, select Add post-build action from the Post-build action menu, and select Scan with Code Insight. The Scan with Code Insight dialog is displayed.

  7. Enter the following information in the Scan with Code Insight dialog:

    • Code Insight core server base URL—Enter the URL for the Code Insight core server (for example, http://codeInsightServer.myorg.org:8888).

    • User access token—Enter the JSON Web Token (JWT) used to authorize user access to the Code Insight functionality. 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.

    • Project name—Enter the name of the Code Insight project to which to send the scan results (for example, Jenkins - Dependencies). This project can be one that already exists on the Code Insight core server or one that the configuration process will create on the core server for you (if you have also selected Create project if doesn’t exist).

    • Create project if doesn’t exist—(Optional) Select this option to create the Code Insight project (specified for Project name) as part of the configuration process if it does not already exist on the Code Insight core server. If the project already exists, this option is ignored.

    • Scan paths—(Optional) To scan a subset of the Jenkins workspace, enter the path for each folder to scan, using commas to separate the paths. Each path should be either a path relative to the workspace or an absolute path.

      If this field is left blank, the entire workspace considered for the scan.

    • Alias—A name that you define for the scan-agent plugin. The alias is used to represent the “container” (scan root) under which all the files scanned in this instance will be listed in the file tree in the Analysis Workbench and in the API output. This name must be unique within the project.

    • Host—(Optional) A user-defined name for the instance where the scan-agent plugin is configured to run scans. This property along with the Alias property will remain unchanged for each subsequent rescan.

      Although generally optional, this value is required if you are running the scan in a dynamic host environment. See Note About Rescans Performed by v2.0 and Later Plugins.

  8. (Optional) Complete these next fields only if the Jenkins HTML Publisher is installed and you intend to have a report generated in Code Insight and made available in Jenkins as part of the build scan process.

    For information about the Jenkins HTML Publisher, see Prerequisites for the Jenkins Scan-Agent Plugin. In addition to the following fields, you must also define parameters for the publication of the report in Jenkins (see Configuring the Publication of the Code Insight Report in Jenkins).

    • Generate report after scan—Select this option to have a Code Insight report generated as part of the Jenkins build process once the scan completes. The report, based on the scan results, is generated in Code Insight and returned to Jenkins so that you can view it.

      At this point, you must click Test Connection to test your connection to the Code Insight server. If the connection succeeds, the Select report dropdown list is populated with available reports.

      If the connection fails (or Generate report after scan is not selected), Select report remains blank and you are unable to continue with the report generation configuration.

    • Select report—Select the specific Code Insight report that you want to generate as part of the Jenkins scan build process once the scan completes. The dropdown list includes all standard and custom reports available on your Code Insight system.

    • Report options—If the report you selected is a custom report that enables users to specify additional report parameters in JSON format, enter those parameters here. For example, if the selected report is defined to require another project (that is, the enableProjectPicker value in the report definition is true), then enter the following required parameter in this field:

      { "otherProjectId": "1" }

      where otherProjectId is the ID of the second project.

  9. If you have not configured report generation (see the previous step), click Test Connection to test your connection to Code Insight.

  10. Click Save. The next time you build, the scan will be performed after the build action. (Before running a scan, ensure that you have met all the requirements in Prerequisites for the Jenkins Scan-Agent Plugin and Setting Heap Size for the Jenkins Scan-Agent Plugin.)