fix(delete): [JENKINS-70252] delete WorkflowRun before WorkflowJob #463
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We use the repository scanning feature in the cloudbees-folder-plugin with Multi Branch Pipeline project to delete non-existent branches. When the folder plugin finds out which branch should be deleted, it calls the delete method in the
I
class (AbstractFolder<I>
), in our case it is WorkflowJob. WorkflowJob only overrides theperformDelete
method, where it disables the job, exits the queue and callsAbstractItem.performDelete()
. This way WorkflowJob only recursively deletes files under it. There is no logic for deleting artifacts under a WorkflowRun. This is why, for example, artifacts are not deleted from S3 after deleting a branch (second case in the linked issue).But if you delete only the WorkflowRun (for example
logRotator
in pipeline options), it will delete artifacts because the parent class callsdeleteArtifacts
in thedelete
method (fisrt case in the linked issue).I believe it would be correct to update
hudson.model.Job
, where to add logic to remove builds (hudson.model.Run
) fromgetBuilds
. But it was much easier to make changes to the plugin and test it in a production environment.Testing done
I really don't know how to test this properly. I just made the changes and tested it in our Jenkins instance. Everything is working as I expected. I will be glad to know how to test this fix.
Submitter checklist
https://issues.jenkins.io/browse/JENKINS-70252