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

Enable credentials in triggers using declarative pipelines

XMLWordPrintable

      Background

      This issue originates from this issue in Generic Webhook Trigger Plugin: https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/107

      The reporter is using declarative pipeline.

      The user wants to get the credential, secret text, and use it when configuring triggers. More specifically as value of the 'token' configuration parameter in the plugin.

      Something like this:

      ...
        environment {
          JENKINS_TOKEN = credentials('JENKINS_TOKEN')
        }
          
        triggers {
          GenericTrigger(
           genericVariables: [
             ...
           ],
           causeString: 'Triggered by $image',
           token: env.JENKINS_TOKEN,
           printContributedVariables: true,
           printPostContent: true
          )
        }
      ...
      

      Problem

      The problem is that the credential, or variables form the environment block, is not available in the triggers block.

       

            Unassigned Unassigned
            tomasbjerre Tomas Bjerre
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: