Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions integration-tests/config/testplan.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"name": "backend-tests",
"templates": ["go"],
"tssc": [{
"tssc": [
{
"git": "github",
"ci": "tekton",
"registry": "quay",
Expand Down Expand Up @@ -51,7 +52,15 @@
"registry": "quay",
"tpa": "remote",
"acs": "remote"
}],
},
{
"git": "bitbucket",
"ci": "jenkins",
"registry": "quay",
"tpa": "remote",
"acs": "remote"
}
],
"tests": ["full_workflow.test.ts"]
}
]
Expand Down
7 changes: 7 additions & 0 deletions src/rhtap/core/integration/git/baseGitProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,11 @@ export abstract class BaseGitProvider implements Git {
): Promise<string>;

public abstract getToken(): string;

public getUsername(): string {
if (!this.secret?.username) {
throw new Error('Username not found in the secret. Please ensure the username is provided.');
}
return this.secret.username;
}
}
2 changes: 2 additions & 0 deletions src/rhtap/core/integration/git/gitInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,6 @@ export interface Git extends IntegrationSecret {
): Promise<string>;

getToken(): string;

getUsername(): string;
}
24 changes: 24 additions & 0 deletions src/rhtap/modification/jenkinsfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ export class EnableTPAVariablesModification implements JenkinsfileModification {
};
}
}

export class EnableGitoAuthUsernameModification implements JenkinsfileModification {
getModification(): ContentModifications {
return {
Jenkinsfile: [
{
oldContent: "/* GITOPS_AUTH_USERNAME = credentials('GITOPS_AUTH_USERNAME') */",
newContent: "GITOPS_AUTH_USERNAME = credentials('GITOPS_AUTH_USERNAME')",
},
],
};
}
}
/**
* Enum of available Jenkinsfile modification types
*/
Expand All @@ -119,6 +132,7 @@ export enum JenkinsfileModificationType {
DISABLE_QUAY_CREDENTIALS = 'DISABLE_QUAY_CREDENTIALS',
ENABLE_COSIGN_PUBLIC_KEY = 'ENABLE_COSIGN_PUBLIC_KEY',
ENABLE_TPA_VARIABLES = 'ENABLE_TPA_VARIABLES',
GITOPS_AUTH_USERNAME = 'GITOPS_AUTH_USERNAME',
}

/**
Expand All @@ -144,6 +158,8 @@ export class JenkinsfileModificationFactory {
return new EnableCosignPublicKeyModification();
case JenkinsfileModificationType.ENABLE_TPA_VARIABLES:
return new EnableTPAVariablesModification();
case JenkinsfileModificationType.GITOPS_AUTH_USERNAME:
return new EnableGitoAuthUsernameModification();
default:
throw new Error(`Unknown Jenkinsfile modification type: ${type}`);
}
Expand Down Expand Up @@ -218,6 +234,14 @@ export class JenkinsfileModifier {
return this;
}

enableGitoAuthUsername(): JenkinsfileModifier {
const modification = JenkinsfileModificationFactory.create(
JenkinsfileModificationType.GITOPS_AUTH_USERNAME
).getModification();
this.container.merge(modification);
return this;
}

getModifications(): ContentModifications {
return this.container.getModifications();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ export class AddJenkinsSecretsCommand extends BaseCommand {
}

private async addGitAuthSecrets(): Promise<void> {
const username = this.git.getUsername();
const password = this.getGitOpsAuthPassword();
await this.jenkinsCI.addCredential(
this.folderName,
Credential.GITOPS_AUTH_PASSWORD,
`fakeUsername:${password}`,
`${username}:${password}`,
CredentialType.USERNAME_PASSWORD
);
}
Expand Down Expand Up @@ -133,6 +134,7 @@ export class AddJenkinsSecretsCommand extends BaseCommand {
throw new Error('Unsupported Git type');
}
}

//add ROX_CENTRAL_ENDPOINT
private async addRoxCentralEndpointSecrets(): Promise<void> {
await this.jenkinsCI.addCredential(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ export class JenkinsfileAndEnvModificationsOnGitopsRepoCommand extends BaseComma

modificationsContainer.merge(
JenkinsfileModifier.create()
.updateKubernetesAgentConfig()
.enableRegistryPassword()
.disableQuayCredentials()
.enableTPAVariables()
.getModifications()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class JenkinsfileAndEnvModificationsOnSourceRepoCommand extends BaseComma

modificationsContainer.merge(
JenkinsfileModifier.create()
.updateKubernetesAgentConfig()
.enableRegistryPassword()
.disableQuayCredentials()
.getModifications()
Expand Down