feature: add crumbIssuer option to jenkins (optional) configuration, improve the UI to show a notification after executing the action: re-build
Signed-off-by: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com>
This commit is contained in:
@@ -411,4 +411,17 @@ describe('JenkinsApi', () => {
|
||||
});
|
||||
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
|
||||
});
|
||||
|
||||
it('buildProject with crumbIssuer option', async () => {
|
||||
const info: JenkinsInfo = { ...jenkinsInfo, crumbIssuer: true };
|
||||
await jenkinsApi.buildProject(info, jobFullName);
|
||||
|
||||
expect(mockedJenkins).toHaveBeenCalledWith({
|
||||
baseUrl: jenkinsInfo.baseUrl,
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
crumbIssuer: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,6 +146,7 @@ export class JenkinsApiImpl {
|
||||
baseUrl: jenkinsInfo.baseUrl,
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
crumbIssuer: jenkinsInfo.crumbIssuer,
|
||||
}) as any;
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef);
|
||||
expect(info).toStrictEqual({
|
||||
baseUrl: 'https://jenkins.example.com',
|
||||
crumbIssuer: undefined,
|
||||
headers: {
|
||||
Authorization:
|
||||
'Basic YmFja3N0YWdlIC0gYm90OjEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNlZGYwMTI=',
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface JenkinsInfo {
|
||||
baseUrl: string;
|
||||
headers?: Record<string, string | string[]>;
|
||||
jobFullName: string; // TODO: make this an array
|
||||
crumbIssuer?: boolean;
|
||||
}
|
||||
|
||||
export interface JenkinsInstanceConfig {
|
||||
@@ -45,6 +46,7 @@ export interface JenkinsInstanceConfig {
|
||||
baseUrl: string;
|
||||
username: string;
|
||||
apiKey: string;
|
||||
crumbIssuer?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +72,7 @@ export class JenkinsConfig {
|
||||
baseUrl: c.getString('baseUrl'),
|
||||
username: c.getString('username'),
|
||||
apiKey: c.getString('apiKey'),
|
||||
crumbIssuer: c.getOptionalBoolean('crumbIssuer'),
|
||||
})) || [];
|
||||
|
||||
// load unnamed default config
|
||||
@@ -81,6 +84,7 @@ export class JenkinsConfig {
|
||||
const baseUrl = jenkinsConfig.getOptionalString('baseUrl');
|
||||
const username = jenkinsConfig.getOptionalString('username');
|
||||
const apiKey = jenkinsConfig.getOptionalString('apiKey');
|
||||
const crumbIssuer = jenkinsConfig.getOptionalBoolean('crumbIssuer');
|
||||
|
||||
if (hasNamedDefault && (baseUrl || username || apiKey)) {
|
||||
throw new Error(
|
||||
@@ -98,12 +102,13 @@ export class JenkinsConfig {
|
||||
|
||||
if (unnamedAllPresent) {
|
||||
const unnamedInstanceConfig = [
|
||||
{ name: DEFAULT_JENKINS_NAME, baseUrl, username, apiKey },
|
||||
{ name: DEFAULT_JENKINS_NAME, baseUrl, username, apiKey, crumbIssuer },
|
||||
] as {
|
||||
name: string;
|
||||
baseUrl: string;
|
||||
username: string;
|
||||
apiKey: string;
|
||||
crumbIssuer: boolean;
|
||||
}[];
|
||||
|
||||
return new JenkinsConfig([
|
||||
@@ -227,6 +232,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider {
|
||||
Authorization: `Basic ${creds}`,
|
||||
},
|
||||
jobFullName,
|
||||
crumbIssuer: instanceConfig.crumbIssuer,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user