Tencent Cloud Code AnalysisTencent Cloud Code Analysis
Guide
API
  • IDE

    • Visual Studio Code TCA Plugin
    • JetBrains IDEs TCA Plugin
  • CNB

    • CNB TCA Plugin
    • CNB TCA Badge
  • Jenkins

    • Jenkins TCA Plugin
  • MCP

    • TCA MCP Server
  • Advanced

    • Intranet Repository Analysis
    • Trigger Analysis via API
    • Optimizing Analysis Speed
    • Improving the Issue Detection Rate
  • Other

    • Issue Ignoring Methods
Try Now
  • Service Agreement
  • Privacy Agreement
  • 简体中文
  • English
Guide
API
  • IDE

    • Visual Studio Code TCA Plugin
    • JetBrains IDEs TCA Plugin
  • CNB

    • CNB TCA Plugin
    • CNB TCA Badge
  • Jenkins

    • Jenkins TCA Plugin
  • MCP

    • TCA MCP Server
  • Advanced

    • Intranet Repository Analysis
    • Trigger Analysis via API
    • Optimizing Analysis Speed
    • Improving the Issue Detection Rate
  • Other

    • Issue Ignoring Methods
Try Now
  • Service Agreement
  • Privacy Agreement
  • 简体中文
  • English
  • IDE

    • Visual Studio Code TCA Plugin
    • JetBrains IDEs TCA Plugin
  • CNB

    • CNB TCA Plugin
    • CNB TCA Badge
  • Jenkins

    • Jenkins TCA Plugin
  • MCP

    • TCA MCP Server

Jenkins TCA Plugin

Supports installing the TCA plugin in Jenkins and triggering code analysis via pipelines.

Installation Guide

  1. Click Download the Jenkins TCA Plugin Installation Package.

  2. Go to the Jenkins page, navigate to System Management -> Plugin Management -> Advanced Settings, upload the downloaded Jenkins TCA Plugin installation package, and deploy it.

Usage Guide

  1. First, create a Team and Project in TCA (skip if already available), and connect to the code repository. For details, refer to Quick Start.

  2. After connecting the repository, go to the code repository page, click Plugin Configuration to enter the TCA Plugin configuration dialog, and select the Jenkins Pipeline tab.

    Plugin Configuration

  3. On the Jenkins Pipeline tab, select the analysis scheme to use. If none exists, create one first (refer to Analysis Scheme).

  4. Click the Generate Jenkinsfile TCA Plugin Configuration button, copy the configuration information, and configure it into the Jenkinsfile under the code repository or Pipeline Script as needed:

    • Code Repository Jenkinsfile Configuration

      Navigate to the root directory of the code repository, copy the generated configuration content into the Jenkinsfile (create the Jenkinsfile if it does not exist; click Learn More for details). In the pipeline, select Pipeline script from SCM, and set the script path to Jenkinsfile.

    • Pipeline Script Configuration

      Go to Jenkins Pipeline, select Pipeline script, copy the generated configuration content into the script, and pull the code repository to be scanned before the Code Analysis step. Use git or the checkout plugin to download the code.

  5. The plugin is now configured. To adjust parameter configurations, refer to the following example:

    pipeline {
      agent any
    
      stages {
        // Example of pulling code
        stage ('Pull Code') {
          steps {
              git 'https://github.com/xxx.git'
          }
        }
    
        stage ('Code Analysis') {
          steps {
            tca (
              // Required parameters
              scmType: 'git', // Code repository type
              repoUrl: 'http://xxx', // Code repository URL
              orgSid: 'xxx', // Team ID (obtain from TCA official website)
              teamName: 'xxx', // Project name (obtain from TCA official website)
              schemeID: xxx, // Analysis scheme ID (obtain from TCA official website)
              token: 'xxx', // Personal credential information (sensitive information, please keep confidential!)
              // Optional parameters
              domain: 'xxx', // TCA URL (used for API requests and report link generation; default: https://tca.tencent.com)
              scanDir: '', // Relative directory to analyze (specify a subdirectory under the code repository as the analysis directory, suitable for analyzing a specific module directory in large repositories; default: scan the root directory of the code repository)
              revision: '', // Analysis version number (can be set via environment variable '{SCM}_COMMIT' (SCM optional: [GIT])); default: current workspace code version
              sourceBranch: '', // Branch name (can be set via environment variable '{SCM}_BRANCH' (SCM optional: [GIT])); default: current workspace code branch; required if no branch was specified during code pull
              targetBranch: '' // Target branch name for comparison (suitable for MR scenarios; can be set via environment variable '{SCM}_TARGET_BRANCH' (SCM optional: [GIT])); default: empty
              total: false, // Whether to perform a full scan (default: false, i.e., incremental scan)
              continueOnThresholdNoPass: false, // Do not block subsequent steps if the gate fails (unchecked by default; blocks subsequent steps)
              // Local analysis parameters
              localScan: true, // Enable local analysis (unchecked by default; performs node analysis)
              clientWorkspace: '', // Client workspace (used for local analysis; default: '~/tca_client')
              preCmd: '', // Pre-command (used when preprocessing is required); default: empty
              buildCmd: '', // Build command (used when analyzing compiled languages); default: empty
              exclude: '', // Directories or files to filter (relative paths; multiple paths separated by commas; path format follows Python fnmatch syntax); default: empty
              include: '' // Directories or files to exclusively analyze (relative paths; multiple paths separated by commas; path format follows Python fnmatch syntax); default: empty
            )
          }
        }
      }
    }
    

    Tips

    You can extract the tca step and write it into any stage of the Jenkins Pipeline as needed!

  6. Detailed explanation of plugin parameters:

    • Required parameters and the domain parameter are automatically generated via the TCA Plugin configuration page.

    • revision and sourceBranch are obtained from the current workspace's code repository version and source branch using local git commands. If retrieval fails, manually configure them or set them via environment variables.

    • The plugin only blocks the pipeline if execution fails or the gate check fails. Setting continueOnThresholdNoPass allows the pipeline to proceed even if the gate check fails.

    • localScan enables local analysis, reusing the current pipeline execution environment instead of sending tasks to a resident node. Local analysis parameters only take effect when localScan=true.

    • Local analysis requires downloading the client. Configure clientWorkspace as the client directory to reuse the client and avoid time-consuming downloads each time.

    • preCmd and buildCmd are only used when the analysis scheme is configured with compiled language tools.

    • The default timeout for local analysis is 2h. Set the timeout via the environment variable TCA_LOCAL_TIMEOUT (unit: h).

  7. Local result files:

    The plugin generates a result file tca_report.json in the current workspace by default. You can also configure the file path via the TCA_RESULT_FILE environment variable. The result file contains the following content:

    • status: success (success)/failure (gate check failed)/error (failure)

    • status_code: 0 (success)/255 (gate check failed)/1 (failure)

    • text: Execution status

    • description: Detailed results

    • url: Analysis result link

    • scan_report: Detailed report

      • lintscan: Code check results

      • duplicatescan: Code duplication rate results

      • cyclomaticcomplexityscan: Cyclomatic complexity results

      • clocscan: Code statistics results

      • qualityscan: Gate check results

Last Updated:: 12/9/25, 2:27 PM
Contributors: faberihe