jenkinsci / jenkinsci/credentials-plugin

[JENKINS-70355] Allow credentials binding in options block

Open
#933 1 comment 0 reactions 0 assignees View on GitHub
component:credentials-binding-plugin component:credentials-plugin imported-jira-issue pipeline priority:minor resolution:unresolved
Dominant language
Java
Stars
134
Forks
258
Avg merge
48m
Merged PRs (30d)
1

Description

Would be nice if credentials could be used within the `Options { }` block.

Currently this is not possible:

 


    options {

        timestamps()

        timeout(time: 15, unit: 'MINUTES')

        disableConcurrentBuilds()

        withCredentials([string(credentialsId: 'thc-wh-teams-notify', variable: "WH_URL")]) {

            office365ConnectorWebhooks([

                [name: "Office 365",

                url: ${WH_URL},

                notifyBackToNormal: false,

                notifyFailure: true,

                notifyRepeatedFailure: false,

                notifySuccess: false,

                notifyAborted: true]

            ])

        }

    }


results in:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 14: Options definitions cannot have blocks @ line 14, column 9.

withCredentials([string(credentialsId: 'thc-wh-teams-notify', variable: "WH_URL")]) {

^

1 error

---
Originally reported by faandg, imported from: Allow credentials binding in options block


  • status: Open
  • priority: Minor
  • component(s): credentials-binding-plugin, credentials-plugin
  • label(s): credentials-binding, pipeline
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-08

Raw content of original issue

Would be nice if credentials could be used within the `Options { }` block.

Currently this is not possible:

 


    options {
        timestamps()
        timeout(time: 15, unit: 'MINUTES')
        disableConcurrentBuilds()
        withCredentials([string(credentialsId: 'thc-wh-teams-notify', variable: "WH_URL")]) {
            office365ConnectorWebhooks([
                [name: "Office 365",
                url: ${WH_URL},
                notifyBackToNormal: false,
                notifyFailure: true,
                notifyRepeatedFailure: false,
                notifySuccess: false,
                notifyAborted: true]
            ])
        }
    }


results in:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 14: Options definitions cannot have blocks @ line 14, column 9.
withCredentials([string(credentialsId: 'thc-wh-teams-notify', variable: "WH_URL")]) {
^

1 error

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.