Skip to content

Custom @Symbol for StashBuildTrigger #73

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
<artifactId>credentials</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>

Choose a reason for hiding this comment

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

Why do we need annotation-indexer?

Copy link
Author

Choose a reason for hiding this comment

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

by only adding the dependency on org.jenkins-ci:symbol-annotation

I get following build error:

[INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (display-info) @ stash-pullrequest-builder ---
[INFO] Ignoring requireUpperBoundDeps in com.google.guava:guava
[INFO] Ignoring requireUpperBoundDeps in com.google.code.findbugs:jsr305
[WARNING] Rule 4: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for org.jenkins-ci:annotation-indexer:1.9 paths to dependency are:
+-org.jenkins-ci.plugins:stash-pullrequest-builder:1.9-SNAPSHOT
+-org.jenkins-ci:symbol-annotation:1.3
+-org.jenkins-ci:annotation-indexer:1.9
and
+-org.jenkins-ci.plugins:stash-pullrequest-builder:1.9-SNAPSHOT
+-org.jenkins-ci.main:jenkins-core:2.60.1
+-org.jenkins-ci:annotation-indexer:1.11
and
+-org.jenkins-ci.plugins:stash-pullrequest-builder:1.9-SNAPSHOT
+-org.kohsuke:access-modifier-annotation:1.14
+-org.jenkins-ci:annotation-indexer:1.4
and
+-org.jenkins-ci.plugins:stash-pullrequest-builder:1.9-SNAPSHOT
+-org.jenkins-ci.plugins:git:3.0.0
+-com.infradna.tool:bridge-method-annotation:1.14
+-org.jenkins-ci:annotation-indexer:1.4
and
+-org.jenkins-ci.plugins:stash-pullrequest-builder:1.9-SNAPSHOT
+-org.jenkins-ci.main:jenkins-core:2.60.1
+-org.jenkins-ci:bytecode-compatibility-transformer:1.8
+-org.jenkins-ci:annotation-indexer:1.4
]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Choose a reason for hiding this comment

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

OK. The way to solve this is to lock the version using dependencyManagement, not to add a new direct dependency.
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management

Copy link
Author

Choose a reason for hiding this comment

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

thx for pointing that out. Moved to dependencyManagement

<version>1.11</version>
</dependency>
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
Expand Down Expand Up @@ -72,9 +73,6 @@ public class StashBuildTrigger extends Trigger<AbstractProject<?, ?>> {

private transient StashPullRequestsBuilder stashPullRequestsBuilder;

@Extension
public static final StashBuildTriggerDescriptor descriptor = new StashBuildTriggerDescriptor();

@DataBoundConstructor
public StashBuildTrigger(
String projectPath,
Expand Down Expand Up @@ -332,6 +330,8 @@ public boolean isOnlyBuildOnComment() {
return onlyBuildOnComment;
}

@Extension
@Symbol("stashPullRequestBuilder")
public static final class StashBuildTriggerDescriptor extends TriggerDescriptor {
public StashBuildTriggerDescriptor() {
load();
Expand Down