com.terrafolio.gradle.plugins.jenkins.PreemptiveAuthInterceptor.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-jenkins-plugin Show documentation
Show all versions of gradle-jenkins-plugin Show documentation
This is a gradle plugin for programmatically configuring Jenkins jobs.
package com.terrafolio.gradle.plugins.jenkins
import java.io.IOException;
import com.sun.net.httpserver.HttpContext
import org.apache.http.HttpException;
import org.apache.http.HttpRequest
import org.apache.http.HttpRequestInterceptor
class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
def String username
def String password
public PreemptiveAuthInterceptor(String username, String password) {
this.username = username
this.password = password
}
@Override
public void process(HttpRequest request,
org.apache.http.protocol.HttpContext context) throws HttpException,
IOException {
request.addHeader('Authorization', 'Basic ' + "${username}:${password}".toString().bytes.encodeBase64().toString())
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy