Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit efcdb89

Browse files
authored
Merge pull request #237 from MicroFocus/octane-dev-latest
Octane 5.7.4 fixes
2 parents 2c1474b + 6374c8e commit efcdb89

File tree

4 files changed

+74
-14
lines changed

4 files changed

+74
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@
470470
<dependency>
471471
<artifactId>integrations-sdk</artifactId>
472472
<groupId>com.hpe.adm.octane.ciplugins</groupId>
473-
<version>2.0.40</version>
473+
<version>2.0.41</version>
474474
</dependency>
475475

476476
<!--BUILDER providers integration-->

src/main/java/com/microfocus/application/automation/tools/octane/configuration/FodConfigUtil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,29 @@ public static Long getFODReleaseFromBuild(AbstractBuild build) {
7878
}
7979

8080
private static Long getRelease(AbstractProject project) {
81+
Long release = getReleaseVersionBefore12(project);
82+
if(release != null){
83+
logger.debug("A Version before 12 is detected.");
84+
return release;
85+
}
86+
87+
release = getReleaseVersion12(project);
88+
if(release != null) {
89+
logger.debug("A Version 12 or higher is detected.");
90+
}
91+
logger.debug("No release was set to this job");
92+
return release;
93+
}
94+
private static Long getReleaseVersion12(AbstractProject project){
95+
for (Object publisher : project.getPublishersList()) {
96+
if (publisher instanceof Publisher &&
97+
FOD_STATIC_ASSESSMENT_STEP.equals(publisher.getClass().getName())) {
98+
return getReleaseByReflectionV12(publisher);
99+
}
100+
}
101+
return null;
102+
}
103+
private static Long getReleaseVersionBefore12(AbstractProject project){
81104
for (Object publisher : project.getPublishersList()) {
82105
if (publisher instanceof Publisher &&
83106
FOD_STATIC_ASSESSMENT_STEP.equals(publisher.getClass().getName())) {
@@ -86,7 +109,14 @@ private static Long getRelease(AbstractProject project) {
86109
}
87110
return null;
88111
}
112+
private static Long getReleaseByReflectionV12(Object fodPublisher) {
89113

114+
Object sharedBuildStep = getFieldValue(fodPublisher, "sharedBuildStep");
115+
if(sharedBuildStep == null){
116+
return null;
117+
}
118+
return getReleaseByReflection(sharedBuildStep);
119+
}
90120
private static Long getReleaseByReflection(Object fodPublisher) {
91121

92122
Object modelObj = getFieldValue(fodPublisher, "model");

src/main/java/com/microfocus/application/automation/tools/octane/model/processors/projects/AbstractProjectProcessor.java

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@
2121
package com.microfocus.application.automation.tools.octane.model.processors.projects;
2222

2323
import com.hp.octane.integrations.dto.pipelines.PipelinePhase;
24-
import com.microfocus.application.automation.tools.octane.model.processors.builders.*;
24+
import com.microfocus.application.automation.tools.octane.executor.UftConstants;
25+
import com.microfocus.application.automation.tools.octane.model.processors.builders.AbstractBuilderProcessor;
26+
import com.microfocus.application.automation.tools.octane.model.processors.builders.BuildTriggerProcessor;
27+
import com.microfocus.application.automation.tools.octane.model.processors.builders.ParameterizedTriggerProcessor;
2528
import com.microfocus.application.automation.tools.octane.tests.build.BuildHandlerUtils;
2629
import hudson.model.*;
2730
import hudson.tasks.Builder;
2831
import hudson.tasks.Publisher;
32+
import jenkins.model.Jenkins;
2933
import org.apache.logging.log4j.LogManager;
3034
import org.apache.logging.log4j.Logger;
3135

@@ -76,28 +80,51 @@ public void scheduleBuild(Cause cause, ParametersAction parametersAction) {
7680
}
7781

7882
public void cancelBuild(Cause cause, ParametersAction parametersAction) {
83+
String suiteId = (String) parametersAction.getParameter(UftConstants.SUITE_ID_PARAMETER_NAME).getValue();
84+
String suiteRunId = (String) parametersAction.getParameter(UftConstants.SUITE_RUN_ID_PARAMETER_NAME).getValue();
85+
logger.info("cancelBuild for suiteId=" + suiteId +", suiteRunId=" + suiteRunId);
7986
if (job instanceof AbstractProject) {
8087
AbstractProject project = (AbstractProject) job;
88+
Queue queue = Jenkins.get().getQueue();
89+
queue.getItems(project).forEach(item -> {
90+
item.getActions(ParametersAction.class).forEach(action -> {
91+
if (checkSuiteIdParamsExistAndEqual(action, suiteId, suiteRunId)) {
92+
try {
93+
logger.info("canceling item in queue : " + item.getDisplayName());
94+
queue.cancel(item);
95+
} catch (Exception e) {
96+
logger.warn("Failed to cancel '" + item.getDisplayName() + "' in queue : " + e.getMessage(), e);
97+
}
98+
}
99+
});
100+
});
101+
81102
project.getBuilds().forEach(build -> {
82103
if (build instanceof AbstractBuild) {
83-
AbstractBuild abuild = (AbstractBuild) build;
84-
abuild.getActions(ParametersAction.class).forEach(action -> {
85-
if (action.getParameter("suiteId").getValue().equals(parametersAction.getParameter("suiteId").getValue())
86-
&& action.getParameter("suiteRunId").getValue().equals(parametersAction.getParameter("suiteRunId").getValue())) {
104+
AbstractBuild aBuild = (AbstractBuild) build;
105+
aBuild.getActions(ParametersAction.class).forEach(action -> {
106+
if (checkSuiteIdParamsExistAndEqual(action, suiteId, suiteRunId)) {
87107
try {
88-
abuild.doStop();
108+
aBuild.doStop();
89109
} catch (Exception e) {
90-
logger.warn(e);
110+
logger.warn("Failed to stop build '" + aBuild.getDisplayName() + "' :" + e.getMessage(), e);
91111
}
92112
}
93113
});
94114
}
95115
});
96116
} else {
97-
throw new IllegalStateException("unsupported job CAN NOT be stop");
117+
throw new IllegalStateException("unsupported job CAN NOT be stopped");
98118
}
99119
}
100120

121+
private boolean checkSuiteIdParamsExistAndEqual(ParametersAction parametersAction, String suiteId, String suiteRunId) {
122+
ParameterValue suiteIdPV = parametersAction.getParameter(UftConstants.SUITE_ID_PARAMETER_NAME);
123+
ParameterValue suiteRunIdPV = parametersAction.getParameter(UftConstants.SUITE_RUN_ID_PARAMETER_NAME);
124+
return (suiteIdPV != null && suiteRunIdPV != null && suiteIdPV.getValue().equals(suiteId)
125+
&& suiteRunIdPV.getValue().equals(suiteRunId));
126+
}
127+
101128
/**
102129
* Retrieve Job's CI ID
103130
* return the job name, in case of a folder job, this method returns the refactored

src/main/java/com/microfocus/application/automation/tools/octane/model/processors/scm/GitSCMProcessor.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ private SCMData enrichLinesOnSCMData(SCMData scmData, AbstractBuild build) {
9797
if (workspace != null) {
9898
File repoDir = new File(getRemoteString(build) + File.separator + ".git");
9999
scmData = workspace.act(new LineEnricherCallable(repoDir, scmData));
100+
logger.info("Line enricher: process took: " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds");
101+
}
102+
else {
103+
logger.warn("Line enricher: workspace is null");
100104
}
101105
} catch (Exception e1) {
102-
logger.error("Line enricher: FAILED. could not enrich lines on SCM Data " + e1);
106+
logger.error("Line enricher: FAILED. could not enrich lines on SCM Data ", e1);
103107
}
104-
logger.info("Line enricher: process took: " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds");
105108
return scmData;
106109
}
107110

@@ -349,7 +352,7 @@ public SCMData invoke(File rootDir, VirtualChannel channel) throws IOException {
349352
df.setDetectRenames(true);
350353

351354
//add blame data to scm data
352-
Set<String> committedFiles = getCommittedFiles(scmData);
355+
Set<String> committedFiles = getAddedOrEditedFiles(scmData);
353356
List<SCMFileBlame> fileBlameList = getBlameData(repo, committedFiles);
354357
scmData.setFileBlameList(fileBlameList);
355358

@@ -396,10 +399,10 @@ public SCMData invoke(File rootDir, VirtualChannel channel) throws IOException {
396399
}
397400
}
398401

399-
private static Set<String> getCommittedFiles(SCMData scmData) {
402+
private static Set<String> getAddedOrEditedFiles(SCMData scmData) {
400403
Set<String> filesCommittedInPPR = new HashSet<>();
401404
for (SCMCommit curCommit : scmData.getCommits()) {
402-
curCommit.getChanges().forEach(change -> filesCommittedInPPR.add(change.getFile()));
405+
curCommit.getChanges().stream().filter(change -> !change.getType().equals("delete")).forEach(change -> filesCommittedInPPR.add(change.getFile()));
403406
}
404407
return filesCommittedInPPR;
405408
}

0 commit comments

Comments
 (0)