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
[JENKINS-34395] Support for tag discovery #158
Conversation
4607dbd
to
0ec2003
Compare
How can you limit what Tags are supported, @stephenc ? If I have a repo with 500 tags I don't want 500 new projects created. Should this be limited to annotated tags? Can it skip "Pre-release" tags? |
An extension plugin can trivially filter tags by date created |
There are several example plugins doing filtering and TagSCMHead.getDate() is the last commit for shallow tags and the tag date for annotated tags (We could add an option to discover annotated tags only/lightweight only/signed only/etc... or maybe make that a filtering concern) |
@stephenc We would want an Environment variable or something that can be used in a @orrc creates two Environment Variables in his Git Tag Message Plugin. Something like that would help. https://wiki.jenkins.io/display/JENKINS/Git+Tag+Message+Plugin @michaelneale @i386 @vivek @abayer Many users have been requesting this functionality. Currently, it wouldn't show up in Blue Ocean. We have had several discussions about how this relates to creating a release or how it might work with a mvn tag. If someone creates a Pipeline with "mvn release" it will create a new tag. This will either create a new job to run if Tags are enabled or it will not show up in the Tags tab like jobs created by Tags. |
you mean something like https://github.com/jenkinsci/branch-api-plugin/blob/master/src/main/java/jenkins/branch/BranchNameContributor.java#L88-L91 (i.e. with this change you get |
Of course if BlueOcean had actually implemented support for SCMHeadCategories, then it would magically just show up... but JENKINS-40367 hasn't had much traction |
I suspect given that BlueOcean is ignorant of categories, tags will show up under branches. Lack of use of categories is also likely the root cause of slow rendering of pull requests tab in BlueOcean that I've seen JIRA for (but on phone I cannot find link for) |
There is also a similar PR for the git-plugin |
blueocean (for GitHub/bitbucket) uses BranchDiscoveryTrait with strategyId 3 to take in all branches - that is all PRs and branches. Looking at this trait, tags won't show up in blueocean without extra work that is do it properly in JENKINS-40367. |
@vivek what I mean is that if the user configured the multibranch project to have the tag discovery trait then they will likely show up as branches in the blue ocean UI |
…sing a hash rather than a ref
c85e43c
to
51fc6ef
Compare
@HRMPW @stephenc im planning on submitting a aged filtering trait once #67 gets merged and released |
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.
Sounds OK to the extent I understand it.
} | ||
return result; | ||
} finally { | ||
Connector.release(github); |
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.
Can this not become [Auto]Closeable
[sic]?
final GHRepository ghRepository = this.ghRepository; | ||
GitHubSCMSourceContext context = new GitHubSCMSourceContext(null, SCMHeadObserver.none()) | ||
.withTraits(traits); | ||
Matcher prMatcher = Pattern.compile("^PR-(\\d+)(-.*)?$").matcher(headName); |
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.
Is there not already some kind of constant for this?
// out tags that are less than X seconds old, but as such a filter would be incompatible with events | ||
// discovering tags, no harm... the key part is that a pre-filter that removes tags older than X days | ||
// will not strip the tag *here* (because it will always be only a few seconds "old"), but when | ||
// the fetch call actually has the real tag date the pre-filter will apply at that point in time. |
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.
Uh, OK. I guess this is all hypothetical unless and until someone writes such a filter.
I'm not well versed in Java-land, but have deployed this to our Jenkins install, and found two things so far:
|
… repos without any tags
@stephenc thanks for the update. How easy would it be to get these changes ported over to the Bitbucket plugin as well? (https://issues.jenkins-ci.org/browse/JENKINS-47254) |
@chris5287 if you want to give it a try i’d be happy to review/mentor. I’m busy on a different project so I don’t have time to implement myself |
@michaelneale This is my GitHub nick. :) |
8768d73
to
e98acfa
Compare
@stephenc can you please advise? the code is the same as you provided here thanks in advance |
+1 the ability to trigger builds when a new tag arrives would be a huge win for us. |
@cleverkidd I created JENKINS-47678 to track that stack trace you identified. That issue is fixed in branch-api 2.0.15 (which should be available from the update centers in the next few hours) |
I feel like I'm missing something on how this is suppose to work. In the org folder setup, I've added the
|
So you would need to have 2.2.6-SNAPSHOT where you build this plugin with this PR merged. (Hint: this plugin has not been merged yet) |
I pulled the latest code from this repo, then rebased the PR code with master, built the hpi, But still not seeing the mention of tags during a Scan?? |
@jeff-knurek did you add “Discover Tags” behaviour? |
that's it!! thanks I looked for that on my first build of the plugin, but it was still missing the change, and didn't look for it again after |
I've run any number of manual and automated tests against this PR, the changes look good to me. I did observe some typical ATH flakiness, and one of the resulting issues is JENKINS-47702. This could be recreated without this PR in place. |
Yay! |
How would I get this on my jenkins server? We're running a container FROM the standard docker container that pulls plugins at build. I'm guessing I just rebuild our container? |
@ahammond I have used my psychic powers to determine exactly how your instance is configured and maintained. While I was doing that I took the liberty of upgrading the plugin for you... eh damn... seems my psychic powers are not working today |
@stephenc The correct answer turns out to be "yeah, if you're pulling plugins at build, you should get the latest version of this plugin the next time you build". Tags are now building for us. Thanks. |
A question about the "build everything plugin" idea. Does the tag fetching distinguish between the initial scan (which might pull in a lot of tags) and subsequent polls/updates/events? i.e. is it possible for me to write a plugin that will build only newly created tags, but not any tags found during the intial scan? (i.e. like to have my Jenkins instance be re-createable, and i don't persist any of the workspace or files from instance to instance.) As a backup I could use the date of the commit the tag is on (we use lightweight tags usually) and just ignore any tag not created in the last X*2 mins (where X is the check interval). |
@ashb this is entirely up to the person writing the BranchBuildStrategy extension... you can have multiple such ones. Build Everything is just the most basic one. I recommend that there would be three or more strategies for building branches, tags and PRs. The tag one could be either simple or it could allow configuration to build based on the tag date (the TagSCMHead mixin has a tag date) |
Sorry, I meant does a strategy plugin have enough info to distinguish those two cases? (first time populating repo vs new tag in a repo that has been scanned before) |
how could it? all it knows is there is now a tag where once there was not and the tag reports a tag date of XYZ (depending on the type of tag that could be the last commit time or the time the heavyweight tag was created) |
but you could have the strategy say "only build tags that are less than X days old and must be after today the time I am saving the form" |
This issue is merged. There is are mailing lists for discussion |
See JENKINS-34395
I believe this to be a full implementation, but test coverage of some aspects of this is non-trivial... OTOH given that it is mostly new functionality that would be needing testing we could just go as is
Downstream of hub4j/github-api#375
@reviewbybees