Skip to content

Update status only if material has changed #140

@alirezamirian

Description

@alirezamirian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions