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

Clean up hooks #403

Merged
merged 3 commits into from
Jan 18, 2023
Merged

Clean up hooks #403

merged 3 commits into from
Jan 18, 2023

Conversation

basil
Copy link
Member

@basil basil commented Jan 14, 2023

Problem

In a number of places, this code base assumed that the parent POM was available, an assumption that is no longer valid after the introduction of incrementals and flatten-maven-plugin. In a few places, the existing code was printing ugly warnings when the parent POM was unavailable and proceeding down an alternate code path.

Solution

This PR begins to address the problem by dealing with AbstractMultiParentHook and its descendants. (#400 turns down the log level for some other cases, and when both of these PRs are merged I will look at what remains and clean up the rest.) There is no need to rely on the parent POM in any of these cases, since an alternative paradigm completely suffices for open-source Jenkins plugin: check that the group ID and artifact ID are as expected for the plugin (see the "gav" section of the Update Center JSON) and that the packaging type is "hpi".

While we were here, we also clarified the getParentFolder and getParentProjectName and made existing implementations consistent. These could probably be removed entirely in the future but we are not going that far in this PR. Once this is merged I will investigate that and file a separate issue if it makes sense.

Testing done

Tested this in context in jenkinsci/bom.

basil added a commit to basil/bom that referenced this pull request Jan 14, 2023
basil added a commit to basil/bom that referenced this pull request Jan 14, 2023
@basil basil marked this pull request as ready for review January 14, 2023 21:01
@basil basil requested a review from a team as a code owner January 14, 2023 21:01
@basil basil requested a review from jtnord January 14, 2023 21:01
Comment on lines +131 to +132
* Return the folder where the multi-module project will be checked out. This should be the name
* of the plugin's Git repository.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really matter one way or another, but to be consistent with plugins that are not multi-module, recommend the name of the Git repository.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we ever have a valid scenario where we have a multi module project with > 1 plugin where we would have different versions of those plugins to test in the release?
if that is the case does using the git repo name cause issues in testing (as you can only have one version checked out at once and then depending what you are running you may have a plugin from both the war and the reactor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware of such a scenario and it doesn't make sense to me that one would ever be mixing plugin versions from the same multi-module project.

Comment on lines +137 to +140
* Return the prefix to the SCM tag (usually the artifact ID of the base module). This will be
* used to form the checkout tag with the format {@code parentProjectName-version} in the (highly
* unlikely, and impossible for incrementalified plugins) event that the SCM tag is missing from
* the plugin's POM.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly useless because it is only used in a fallback code path, but at least document the convention that would make that fallback path work.


@Override
protected String getParentFolder() {
return "aws-java-sdk";
return "aws-java-sdk-plugin";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with the Javadoc.

Comment on lines +20 to +26
PomData data = (PomData) info.get("pomData");
return ("org.jenkins-ci.plugins".equals(data.groupId)
&& "aws-java-sdk".equals(data.artifactId)
&& "hpi".equals(data.getPackaging()))
|| ("org.jenkins-ci.plugins.aws-java-sdk".equals(data.groupId)
&& data.artifactId.startsWith("aws-java-sdk")
&& "hpi".equals(data.getPackaging()));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From update-center-sql:

sqlite> select gav from plugins where name like 'aws-java-sdk%';
org.jenkins-ci.plugins:aws-java-sdk:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-cloudformation:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-codebuild:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-ec2:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-ecr:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-ecs:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-efs:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-elasticbeanstalk:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-iam:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-logs:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-minimal:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-sns:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-sqs:1.12.287-357.vf82d85a_6eefd
org.jenkins-ci.plugins.aws-java-sdk:aws-java-sdk-ssm:1.12.287-357.vf82d85a_6eefd

@@ -11,11 +9,9 @@
*/
public class BlueOceanHook extends AbstractMultiParentHook {

private static final Logger LOGGER = Logger.getLogger(BlueOceanHook.class.getName());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing unused code.

import java.util.logging.Logger;
import org.jenkins.tools.test.model.PomData;

public class StructsHook extends AbstractMultiParentHook {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structs was flattened a while ago, and this hook was only needed to test older versions where it is not flattened. Since I do not think there are any consumers left that would be trying to run PCT on old versions of structs, deleting this hook.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update this javadoc comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 57170b6

@Override
protected String getParentFolder() {
return "swarm";
return "swarm-plugin";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with the Javadoc.

Comment on lines +27 to +30
PomData data = (PomData) info.get("pomData");
return "org.jenkins-ci.plugins".equals(data.groupId)
&& "swarm".equals(data.artifactId)
&& "hpi".equals(data.getPackaging());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From update-center-sql:

sqlite> select gav from plugins where name like 'swarm%';
org.jenkins-ci.plugins:swarm:3.39

@@ -13,7 +14,7 @@ protected String getParentFolder() {

@Override
protected String getParentProjectName() {
return "workflow-cps-parent";
return "workflow-cps";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with the tagging scheme of this repository, not that it matters since this was a fallback code path. Since this file was added recently, the mistake here just serves to illustrate how poor the old Javadoc was (corrected in this PR).

Comment on lines +34 to +37
return "org.jenkins-ci.plugins.workflow".equals(data.groupId)
&& "workflow-cps".equals(data.artifactId)
&& pluginVersion.isNewerThan(multiModuleSince)
&& "hpi".equals(data.getPackaging());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the same convention used elsewhere by checking the group ID, artifact ID, and packaging type. In this case we also need to check the version to see if it is one where the plugin is single-module or multi-module.

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks ok - will setup a job to test this with our proprietary code.

@basil
Copy link
Member Author

basil commented Jan 17, 2023

code looks ok - will setup a job to test this with our proprietary code.

Thanks, let me know when the build is green and I will squash merge this

@jtnord
Copy link
Member

jtnord commented Jan 18, 2023

downstream closed source build is passing - this is good to merge.

@basil basil merged commit fc56d5a into master Jan 18, 2023
@basil basil deleted the hooks-cleanup branch January 18, 2023 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants