BitbucketTagSCMHead does not receive an annotated tag date
ryancurrah opened this issue · 6 comments
Jenkins and plugins versions report
Environment
Jenkins: 2.346.1.4
OS: Ubuntu - 18.04
---
cloudbees-bitbucket-branch-source:773.v4b_9b_005b_562b_
What Operating System are you using (both controller, and any agents involved in the problem)?
Controller: ubuntu 1804
Agent: ubuntu 1804
Reproduction steps
- Install the https://plugins.jenkins.io/bitbucket-scm-filter-aged-refs plugin in Jenkins.
- Create a Bitbucket project and setup an existing repository with a commit older than one 1 day (I used this repository to test).
- Setup an
Organization Folder
to scan the created Bitbucket project, configureFilter by ref age
discovery trait, to filter tags created after 1 days. (Remember to enableDiscover Tags
) - Create an annotated git tag (EG
git tag -m "" v0.0.0
) from a commit that is older than 1 day and push the tag. Click theScan Multibranch Pipeline Now
button in the repository folder. View the logs inScan Multibranch Pipeline Log
.
Expected Results
When the Scan Multibranch Pipeline
job runs it should not skip annotated tags that were created less than a day ago where the commit is older than a day.
Actual Results
The bitbucket-branch-source-plugin
plugin is not providing the annotated tags create date and instead the commits date to the BitbucketTagSCMHead
constructor.
Anything else?
As per GitTagSCMHead
class which BitbucketTagSCMHead
extends.
The timestamp
parameter to the GitTagSCMHead
constructor should be...
The timestamp of the tag, for lightweight tags this should be the last commit, for annotated tags this should be the tag date.
I've spent a day trying to understand this plugins code and I found where the BitbucketTagSCMHead
is being constructed but I can't tell how the timestamp value is generated.
There is a TODO in the code that mentions supporting this, but I have no Idea if it's related or how we would add that support.
Return timestamp of last commit or of tag if its annotated tag.
// TODO figure out how to implement this
If someone could help me understand this a little better I may be able to produce the fix myself.
Is this with Bitbucket Cloud or Bitbucket Server?
On Bitbucket Server, GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags and GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name} return RestTag objects that contain the tag name, tag object ID, and commit ID, but not the tagger date. I don't know whether it is possible to query the tagger date over the REST API, or whether that would require fetching the tag object over the Git protocol (which might then require fetching commit, tree, and blob objects as well).
On Bitbucket Cloud, GET /2.0/repositories/{workspace}/{repo_slug}/refs/tags/{name} returns the tagger date, too.
Sorry that was a newb mistake. I am using Bitbucket server. Interesting that the commit date is determined by querying the API. I'll do some research on the API of Bitbucket server. Though I'm pretty familiar with it and I don't think there is a way to get the tag create date without cloning the project.
Yeah it appears it's not possible in Bitbucket server without cloning.
I looked at Bitbuckets JIRA issues and found an issue where someone is asking for Bitbucket to support listing tags and getting their create date. I added a comment to it and linked it to this issue.