Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Bearer Token Authentication #62

Merged
merged 3 commits into from
Jan 4, 2020

Conversation

bsquizz
Copy link

@bsquizz bsquizz commented Jan 2, 2020

When Jenkins is running on top of OpenShift, bearer token authentication is used for all REST API calls.

This means the API requests are authenticated via a header like:
Authorization: Bearer <Kubernetes/OpenShift Token>

I've been using these modifications to the plugin to trigger remote jobs on a master deployed on OpenShift with the OpenShift authentication enabled.

Example usage in a pipeline:

    def jobParameters = [[$class: StringParameterValue, name: "someParam", value: "someValue"]]
    // Translate the params into a string
    def paramsString = ""
    for (Map p : jobParameters) {
        paramsString = paramsString + "\n${p['name']}=${p['value'].toString()}"
    }

    withCredentials([
        string(credentialsId: remoteCredentials, variable: "TOKEN"),
        string(credentialsId: remoteHostname, variable: "REMOTE_HOSTNAME")
    ]) {
        triggerRemoteJob(
            job: "https://${REMOTE_HOSTNAME}/job/path/to/job",
            parameters: paramsString,
            auth: BearerTokenAuth(token: TOKEN)
        )
    }

Copy link

@cashlalala cashlalala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for the contribution

@cashlalala cashlalala merged commit 2b067fe into jenkinsci:master Jan 4, 2020
@daniel-beck
Copy link
Member

This has no UI in the global configuration, and the HTML help hasn't been updated either (in a while, it seems).

Screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants