Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-75896

Gerrit Trigger commentAdded Configuration Fails for Specific verdictCategory in Pipeline Projects

XMLWordPrintable

      Summary

      In Jenkins Pipeline projects, the Gerrit Trigger plugin's commentAdded event trigger fails to work when using verdictCategory: 'Code Review', while the same configuration works correctly in Freestyle projects and verdictCategory: 'Verified' works fine in Pipeline projects.

      Issue Type

      Bug

      Environment

      • Jenkins Version: 2.510
      • Gerrit Trigger Plugin Version: 2.42.0
      • Gerrit Server Version: 3.11.2
      • Operating System: Linux

      Description

      Issue Summary

      When configuring Gerrit Trigger's commentAdded event in Jenkins Pipeline projects, we observed inconsistent behavior:

      1. ✅ Freestyle Project + verdictCategory: 'Code Review' → Works correctly
      1. ❌ Pipeline Project + verdictCategory: 'Code Review' → Does not work
      1. ✅ Pipeline Project + verdictCategory: 'Verified' → Works correctly
      1. ✅ Pipeline Project + patchsetCreated → Works correctly

      Steps to Reproduce

      Step 1: Create Pipeline Project

      Configuration:
       groovy
       
      pipeline {
          agent { node 

      { label 'manual' }

       }
          
          triggers 

      {         gerrit(             serverName: 'mifit',             silentMode: true,             gerritProjects: [[                 branches: [[compareType: 'ANT', pattern: '**']],                 compareType: 'ANT',                 pattern: 'devops/dashboard2'             ]],             triggerOnEvents: [                 commentAdded(verdictCategory: 'Code Review', commentAddedTriggerApprovalValue: '+2')             ]         )     }

          
          stages {
              stage('Test') {
                  steps 

      {                 echo "Pipeline triggered by Code Review"             }

              }
          }
      }
       
      Step 2: Create Comparable Freestyle Project
      Using identical Gerrit Trigger configuration:

      • Server: mifit
      • Project: devops/dashboard2
      • Trigger: Comment Added
      • Verdict Category: Code Review
      • Approval Value: +2

      Step 3: Test Triggering

      In Gerrit, perform the following actions on the same patch:

      1. Give Code Review +2
      1. Give Verified +1

      Expected Result

      • Both Pipeline and Freestyle projects should be triggered when receiving Code Review +2
      • Pipeline project should be triggered when receiving Verified +1

      Actual Result

      Based on Jenkins log observations:

      When giving Verified +1:

       
       
      2025-07-16 15:04:19.065+0000 [id=599070] INFO c.s.h.p.g.t.h.EventListener#schedule: Project TEST_TRIGGER_BY_PIPELINE Build Scheduled: true By event: 927580/1
      2025-07-16 15:04:19.065+0000 [id=599070] INFO c.s.h.p.g.t.h.EventListener#schedule: Project TEST_TRIGGER_BY_CODEREVIEW Build Scheduled: true By event: 927580/1
       
       
      ✅ Both projects were triggered

      When giving Code Review +2:

       
      2025-07-16 15:05:22.204+0000 [id=598997] INFO c.s.h.p.g.t.h.EventListener#schedule: Project TEST_TRIGGER_BY_CODEREVIEW Build Scheduled: true By event: 927580/1
       
      ❌ Only Freestyle project was triggered, Pipeline project was not triggered

      Additional Information

      Ruled Out Potential Causes:

      1. ❌ "New Pipeline needs manual run once" - Project was already manually executed
      1. ❌ Configuration syntax errors - Same syntax works for verdictCategory: 'Verified'
      1. ❌ Server connection issues - Freestyle project works fine, Verified triggering also works
      1. ❌ Permission issues - Same user and project in Freestyle configuration works correctly

      Tested Configuration Variants:

      • verdictCategory: 'Code Review' ❌
      • verdictCategory: 'Huami Code Review' ❌
      • commentAddedTriggerApprovalValue: '+2' / '2' / '+1' ❌
      • Without specifying verdictCategory (catch all comments) ✅

      Confirmed Working Configurations:

       
       
      // ✅ Works correctly in Pipeline
      commentAdded(verdictCategory: 'Verified', commentAddedTriggerApprovalValue: '+1')
       
      // ✅ Works correctly in Freestyle  
      commentAdded(verdictCategory: 'Code Review', commentAddedTriggerApprovalValue: '+2')
       
       
       
      Impact
      This issue prevents teams using Pipeline for CI/CD from properly configuring triggers based on Code Review scores, forcing them to either use patchsetCreated (triggers on every commit) or revert to Freestyle projects, impacting adoption of modern Jenkins Pipeline.

      Suggested Fix

      Recommend investigating the Gerrit Trigger plugin's handling of commentAdded events in Pipeline projects, specifically examining if there are differences in processing logic for different verdictCategory values, particularly Code Review-related categories.

            rsandell rsandell
            junxian jun
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: