-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: master
Are you sure you want to change the base?
Conversation
…elineTrigger in a pipeline script java.lang.NoSuchMethodError: No such DSL method 'stashBuildTrigger' found among steps [archive, bat, build, catchError, ... at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:199) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
Isn't this a duplicate of #69 ? |
It is related. I first created a PR to be included in #69 (https://github.com/proski/stash-pullrequest-builder-plugin/pull/2), but the author saw it as a separate issue. @proski |
OK, so it's blocked by #69 |
Just like #72, this PR can be applied to the master branch independently, without breaking anything. Unlike #72, this PR needs pipelines to be testable, as it defines a symbol to be used in pipelines. So the "blocked" designation is more reasonable here. A few questions about the code:
We should also think hard about the name of the command. Other symbols applied to trigger descriptors are To complicate the matter, Stash is being renamed to Bitbucket Server, stash-notifier is already transitioning to the new name, so we should also plan to have "bitbucket" in the name while being distinct from the other Bitbucket plugins. |
We have way too many jobs to configure them all by hand. All our configuration (parameters, triggers, logrotation, ...) is included in the (git-versioned) pipeline Jenkinsfile. Jenkins takes into account this file at first build and all configuration is automatically "added" to the GUI as well.
No problem to add, but why do we need that? I don't see it mentioned here: https://github.com/jenkinsci/bitbucket-pullrequest-builder-plugin/blob/master/pom.xml
The field is not used, my changes were based on |
OK, fair enough.
Ideally to make it compile. But I see that we are importing
The field is not used, but you also removed the call to I believe the description should be changed. Why would you expect |
Now the static inner class StashBuildTriggerDescriptor is annotated with
Actually, it currently is in the Pipeline Snippet Generator:
|
Thank you for explaning I tried the "properties" in the pipeline snippet generator, I actually had to rename I tried using a different name in If I use a different name, say, If I use no I think |
Do you mean only the |
If we use stucts classes in our source code (which we do, e.g Symbol) we should have a direct compile-scope dependency in pom.xml |
This is also how I understand this works. You can use a default identifier derived from the class name or use Symbol to override it. |
I fail to see where we depend on structs: |
You are right, I just did a quick google and found this: https://github.com/jenkinsci/structs-plugin/blob/master/annotation/src/main/java/org/jenkinsci/Symbol.java which made me think it's in the structs plugin. |
pom.xml
Outdated
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci</groupId> | ||
<artifactId>annotation-indexer</artifactId> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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] ------------------------------------------------------------------------
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
I'm not convinced this PR needs to be applied at all. The description misrepresents the issue as a bug. It is possible to specify the trigger in the properties without an alias. That's what the pipeline snippet generator would produce. Another issue is that the alias would have the name "stash" in it. Stash is Bitbucket Server now. We should plan how to switch to using the new name. This PR gets us in the opposite direction. I'm ready to check this PR for the good bits, but only after #69 is merged. Considering that the simpler and non-controversial PR #72 has been in the "blocked" state for months, I'm not interested in spending time on any code that depends on the pipeline support, even indirectly. |
@proski I think we can close this PR unless we want a custom symbol (which I think we don't)? |
I agree. We can get back to it later. I don't care about the custom symbol. The pipeline generator doesn't require it. |
On second thoughts (see https://github.com/jenkinsci/stash-pullrequest-builder-plugin/compare/1ada98a68af0fd89fe227ff9935515261492b646..c58ca972274cc22fcc316c7c1cb56fef5cd2f291#discussion_r305900208) I think we need to settle on a symbol to use in Jenkinsfiles before we do a release |
Can you post an sample of how to use Child of
|
@herman-nu In the declarative pipeline (i.e. the one with the top-level
Some standard properties can be in the |
Fix java.lang.NoSuchMethodError when using stashBuildTrigger as a pipelineTrigger in a pipeline script
e.g.
properties([ pipelineTriggers([ stashBuildTrigger( projectPath: null, cron: "* * * * *", stashHost: "https://my-stash", credentialsId: 'my-credentialsId', projectCode: "my-project-code", repositoryName: "my-repository", ciSkipPhrases: "NO TEST", ignoreSsl: true, checkDestinationCommit: false, checkMergeable: false, mergeOnSuccess: false, checkNotConflicted: true, onlyBuildOnComment: true, ciBuildPhrases: "test this please", deletePreviousBuildFinishComments: false, targetBranchesToBuild: null, cancelOutdatedJobsEnabled: false ) ]) ])
java.lang.NoSuchMethodError: No such DSL method 'stashBuildTrigger' found among steps [archive, bat, build, catchError, ...