Skip to content

Commit

Permalink
ADNCD-1948: Add workaround for all PRs being rebuilt after GitHub mig…
Browse files Browse the repository at this point in the history
…ration

On initial load of a PR material (handleGetLatestRevision), store all
seen PRs, not just the one we're building. For subsequent loads
(handleLatestRevisionSince) behave the same as before, and only store
the PR we're building.

Also tried fancier variants where you can configure the behavior per PR
material, even allowing to clear the state and rebuild everything.
However, there seems to be a GoCD caching bug such that PR material
config changes in the UI are properly displayed, but not actually
propagated to the PR plugin. It keeps using the old config until
GoCD is restarted, or the PR material (and due to dependency the
referencing config repo) is removed and readded.
  • Loading branch information
Sandro Heinzelmann committed Aug 19, 2024
1 parent 9aa746d commit 87cb80d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>in.ashwanthkumar</groupId>
<artifactId>gocd-github-pr-material</artifactId>
<version>1.6.0</version>
<version>1.6.1_migr1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.tw.go.plugin.util.ListUtil;
import com.tw.go.plugin.util.StringUtil;
import in.ashwanthkumar.gocd.github.provider.Provider;
import in.ashwanthkumar.gocd.github.provider.github.GitHubProvider;
import in.ashwanthkumar.gocd.github.settings.scm.PluginConfigurationView;
import in.ashwanthkumar.gocd.github.util.BranchFilter;
import in.ashwanthkumar.gocd.github.util.ExtendedGitCmdHelper;
Expand Down Expand Up @@ -227,7 +228,12 @@ GoPluginApiResponse handleGetLatestRevision(GoPluginApiRequest goPluginApiReques
}

// Remove all other branches from the response to ensure the next time those will be picked up by GoCD
branchToRevisionMap.entrySet().removeIf(entry -> !Objects.equals(entry.getKey(), newerRevision.getKey()));
if (provider instanceof GitHubProvider) {
LOGGER.info("Storing all seen PRs for initial GitHub PR material load.");
}
else {
branchToRevisionMap.entrySet().removeIf(entry -> !Objects.equals(entry.getKey(), newerRevision.getKey()));
}

Revision revision = git.getDetailsForRevision(newerRevision.getValue());
String branch = newerRevision.getKey();
Expand Down

0 comments on commit 87cb80d

Please sign in to comment.