Skip to content

Commit

Permalink
F2600026 - support GitLab SCM data changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abangau committed Sep 16, 2024
1 parent 371f4cf commit b92f61d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
<dependency>
<artifactId>integrations-sdk</artifactId>
<groupId>com.hpe.adm.octane.ciplugins</groupId>
<version>2.24.3.1</version>
<version>2.24.3.2</version>
</dependency>

<!--BUILDER providers integration-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ public static AuthenticationStrategy getAuthenticationStrategy(StandardCredentia
return authenticationStrategy;
}

public static String getCredentialsPassword(StandardCredentials credentials) {
if (credentials == null) {
return "";
} else if (credentials instanceof StringCredentials) {
return ((StringCredentials) credentials).getSecret().getPlainText();
} else if (credentials instanceof StandardUsernamePasswordCredentials) {
return ((StandardUsernamePasswordCredentials) credentials).getPassword().getPlainText();
} else {
return "";
}
}

public static void updateRepoTemplates(PullRequestAndBranchService pullRequestAndBranchService, FetchHandler fetcherHandler, String repoHttpUrlForTemplates, String repoUrlForOctane, Long workspaceId, Consumer<String> logConsumer) {
//update repo templates
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public void performInternal(@Nonnull Run<?, ?> run, @Nonnull TaskListener taskLi

try {
//GET BRANCHES FROM CI SERVER
FetchHandler fetchHandler = FetchFactory.getHandler(ScmTool.fromValue(myScmTool), authenticationStrategy);
String secret = GitFetchUtils.getCredentialsPassword(credentials);
FetchHandler fetchHandler = FetchFactory.getHandler(ScmTool.fromValue(myScmTool), authenticationStrategy, secret);

OctaneClient octaneClient = OctaneSDK.getClientByInstanceId(myConfigurationId);
logConsumer.printLog("ALM Octane " + octaneClient.getConfigurationService().getConfiguration().getLocationForLog() + ", workspace - " + myWorkspaceId);
Expand Down Expand Up @@ -211,6 +212,7 @@ private BranchFetchParameters createFetchParameters(@Nonnull Run<?, ?> run, @Non
fp.setPageSize(getIntegerValueParameter(parameterAction, "branches_page_size"));
fp.setActiveBranchDays(getIntegerValueParameter(parameterAction, "branches_active_branch_days"));
fp.setMaxBranchesToFill(getIntegerValueParameter(parameterAction, "branches_max_branches_to_fill"));
fp.setSearchBranchOctaneRootRepositoryId(getIntegerValueParameter(parameterAction, "search_branch_octane_root_repository_id"));
}

logConsumer.accept("Repository URL : " + fp.getRepoUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public void performInternal(@Nonnull Run<?, ?> run, @Nonnull TaskListener taskLi
StandardCredentials credentials = GitFetchUtils.getCredentialsById(myCredentialsId, run, taskListener.getLogger());
AuthenticationStrategy authenticationStrategy = GitFetchUtils.getAuthenticationStrategy(credentials);

FetchHandler fetchHandler = FetchFactory.getHandler(ScmTool.fromValue(myScmTool), authenticationStrategy);
String secret = GitFetchUtils.getCredentialsPassword(credentials);
FetchHandler fetchHandler = FetchFactory.getHandler(ScmTool.fromValue(myScmTool), authenticationStrategy, secret);
try {
OctaneClient octaneClient = OctaneSDK.getClientByInstanceId(myConfigurationId);
logConsumer.printLog("ALM Octane " + octaneClient.getConfigurationService().getConfiguration().getLocationForLog() + ", workspace - " + myWorkspaceId);
Expand Down Expand Up @@ -205,6 +206,7 @@ private PullRequestFetchParameters createFetchParameters(@Nonnull Run<?, ?> run,
fp.setMaxPRsToFetch(getIntegerValueParameter(parameterAction, "pullrequests_max_pr_to_collect"));
fp.setMaxCommitsToFetch(getIntegerValueParameter(parameterAction, "pullrequests_max_commits_to_collect"));
fp.setMinUpdateTime(getLongValueParameter(parameterAction, "pullrequests_min_update_time"));
fp.setSearchBranchOctaneRootRepositoryId(getIntegerValueParameter(parameterAction, "search_branch_octane_root_repository_id"));
}
if (fp.getMinUpdateTime() == PullRequestFetchParameters.DEFAULT_MIN_UPDATE_DATE) {
long lastUpdateTime = OctaneSDK.getClientByInstanceId(myConfigurationId).getPullRequestAndBranchService().getPullRequestLastUpdateTime(myWorkspaceId, fp.getRepoUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
You can change the behaviour of this step by adding the following parameters to the job:
<ul>
<li><b>branches_active_branch_days</b>: Only active branches can be added/updated to ALM Octane. Default is 60 days.</li><br>
<li><b>branches_max_branches_to_fill</b>: Relevant for GitHub repository only. Max branches to collect data. If data is not collected from a branch, it cannot be added to ALM Octane. Default is 1000.</li><br>
<li><b>branches_max_branches_to_fill</b>: Relevant for GitHub and GitLab repository only. Max branches to collect data. If data is not collected from a branch, it cannot be added to ALM Octane. Default is 1000.</li><br>
<li><b>search_branch_octane_root_repository_id</b>: The plugin will look through the branches that are linked to the SCM Repository with the configured Id. If a branch has the same name and Last commit revision as one of those branches, they will be considered as duplicates and new branches won't be created in ALM Octane.</li><br>
</ul>

<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<li><b>pullrequests_min_update_time</b>: Use this parameter to override the last update time that is updated after each successful injection to ALM Octane.</li><br>
<li><b>pullrequests_max_pr_to_collect</b>: Max number of pull requests to collect. Default is 100.</li><br>
<li><b>pullrequests_max_commits_to_collect</b>: Max number of commits to collect for each pull request. Default is 100.</li><br>
<li><b>search_branch_octane_root_repository_id</b>: The plugin will look through the branches that are linked to the SCM Repository with the configured Id. If a pull request has the source branch or target branch wit hte same name as one of those branches, they will be considered as duplicates and new branches won't be created in ALM Octane.</li><br>
</ul>

<br>
Expand Down

0 comments on commit b92f61d

Please sign in to comment.