Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update status only if material has changed #140

Open
alirezamirian opened this issue Dec 10, 2020 · 0 comments
Open

Update status only if material has changed #140

alirezamirian opened this issue Dec 10, 2020 · 0 comments

Comments

@alirezamirian
Copy link

It's common to have many repositories that follow the same structure, in a way that you could have a single general pipeline with multiple materials and figure out which one to build based on GO_MATERIAL_[MATERIAL_NAME]_HAS_CHANGED env variables.
Right now, if we do so, all pull requests in different materials will be updated no matter if they triggered the pipeline or not. It would be nice if a check is added here:

for (Map materialRevision : materialRevisions) {
Map material = (Map) materialRevision.get("material");
if (isMaterialOfType(material, provider.pollerPluginId())) {
Map materialConfiguration = (Map) material.get("scm-configuration");
String url = (String) materialConfiguration.get("url");
List<Map> modifications = (List<Map>) materialRevision.get("modifications");
String revision = (String) modifications.get(0).get("revision");
Map modificationData = (Map) modifications.get(0).get("data");
String prId = (String) modificationData.get("PR_ID");
if (StringUtils.isEmpty(prId)) {
prId = (String) modificationData.get("CURRENT_BRANCH");
}
try {
provider.updateStatus(url, pluginSettings, prId, revision, pipelineStage, result, trackbackURL);
} catch (Exception e) {
LOGGER.error(String.format("Error occurred. Could not update build status - URL: %s Revision: %s Build: %s Result: %s", url, revision, pipelineInstance, result), e);
}
}
}

to run updateStatus only if that material has changed. It makes sense to me to have that check unconditionally, but at least it can be a configuration if I'm missing something.

@alirezamirian alirezamirian changed the title update status only if material has changed Update status only if material has changed Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant