Enable credentials in triggers using declarative pipelines

This issue is archived. You can view it, but you can't modify it. Learn more

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.

       

            Assignee:
            Unassigned
            Reporter:
            Tomas Bjerre
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: