jenkinsci / jms-messaging-plugin

https://plugins.jenkins.io/jms-messaging
12 stars 38 forks source link

Build trigger does not support Declarative syntax #149

Open mikebonnet opened 4 years ago

mikebonnet commented 4 years ago

CIBuildTrigger only supports use via pipelineTriggers() in Scripted pipeline, not the triggers{} section of Declarative pipeline. This requires us to maintain pipelines in both formats, depending on how they're triggered. It would be great if CIBuildTrigger supported Declarative pipelines.

scoheb commented 4 years ago

Seems the snippet generator may be broken, it displays:

no public field ‘providerList’ (or getter method) found in class com.redhat.jenkins.plugins.ci.CIBuildTrigger

scoheb commented 4 years ago

The declarative snippet generator is broken for the plugin with triggers. But this works:


    triggers {
        ciBuildTrigger(noSquash: false,
                providerList: [
                        activeMQSubscriber(name: "Red Hat UMB Stage",
                                overrides: [topic: 'Consumer.rh-jenkins-ci-plugin.494a9965465867b680567fc807007b23.VirtualTopic.eng.ci.example.durable.test.494a9965465867b680567fc807007b23']
                        )
                ]
        )
    }
Michkov commented 4 years ago

Does not work for me:

pipeline {
    agent {node {label 'master'}}
    triggers {
        ciBuildTrigger(noSquash: false,
                providerList: [
                        activeMQSubscriber(name: "Red Hat UMB",
                                overrides: [topic: 'Consumer.rh-jenkins-ci-plugin.494ae965465867b680567fc807007b23.VirtualTopic.eng.ci.example.durable.test.494a9965465867b680567fc807007b23'],
                                selector: "CI_NAME = 'test-trigger'",
                        )
                ]
        )
    }

    stages {
        stage('test'){
            steps {
                script {
                    sh 'env'
                }
            }
        }
    }
}

In log:

Dec 06, 2019 12:33:10 PM INFO com.redhat.jenkins.plugins.ci.ProjectChangeListener onUpdated
No CIBuildTrigger found, forcing thread stop.
Dec 06, 2019 12:33:10 PM INFO com.redhat.jenkins.plugins.ci.CIBuildTrigger stopTriggerThreads
Removed thread lock for 'pipeline-test-message'.
scoheb commented 4 years ago

Here is an example of what is known to work:

  ciBuildTrigger {
    providers {
      providerDataEnvelope {
        providerData {
          activeMQSubscriber {
            name("Red Hat UMB")
            overrides {
              def uuid = "4ba46bbc-949b-11e8-b83f-54ee754ea14c"
              topic("Consumer.rh-jenkins-ci-plugin.${uuid}.VirtualTopic.eng.ci.redhat-container-image.pipeline.running")
            }
            // Message Checks
            checks {
              msgCheck {
                field('$.artifact.type')
                expectedValue("cvp")
              }
            }
          }
        }
      }
    }
    noSquash(true)
  }
}

Unfortunately the Pipeline or Job DSL Snippet Generator does not produce this currently.

Michkov commented 4 years ago

My example works after job is executed manually, that's known limitation https://issues.jenkins-ci.org/browse/JENKINS-47539