jenkinsci / generic-webhook-trigger-plugin

Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
https://plugins.jenkins.io/generic-webhook-trigger
404 stars 159 forks source link

i'm trying to automate GenericWebhooktrigger plugin and call from shared libraries #259

Closed KARTHIK031 closed 1 year ago

KARTHIK031 commented 1 year ago

Groovy scrpit:

def createGenericTrigger(Map configParams = [:]) { def branch = '$.push.changes[0].new.name' def regexFilter = configParams.regexFilter ?: '' def token = configParams.token ?: '' def tokenCredentialId = configParams.tokenCredentialId ?: '' return triggers.GenericTrigger( causeString: 'Generic Cause', genericVariables: [ [defaultValue: '', key: 'branch', regexpFilter: '', value:'$.push.changes[0].new.name'] ], printContributedVariables: true, printPostContent: true, regexpFilterExpression: 'branch', regexpFilterText: '$branch', token: 'token', tokenCredentialId: '' ) }

import org.jenkinsci.plugins.GenericWebhookTrigger

import groovy.json.JsonOutput

pipeline { agent any stages { stage('build') { steps { script { createGenericTrigger('branch', 'repo-name')

    }
  }
}
      }
    }

i'm trying to automate Genericwebhooktrigger plugin and call from shared libraries

tomasbjerre commented 1 year ago

If you are having trouble getting the syntax correct, you may want to use the syntax generator: https://www.jenkins.io/doc/book/pipeline/getting-started/#snippet-generator

If you open an issue here, make sure it is an issue with the plugin and not a general question about Jenkins and shared libraries.