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

BitbucketTagSCMHead does not receive an annotated tag date #642

Open
ryancurrah opened this issue Aug 31, 2022 · 7 comments
Open

BitbucketTagSCMHead does not receive an annotated tag date #642

ryancurrah opened this issue Aug 31, 2022 · 7 comments
Labels

Comments

@ryancurrah
Copy link

ryancurrah commented Aug 31, 2022

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, configure Filter by ref age discovery trait, to filter tags created after 1 days. (Remember to enable Discover 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 the Scan Multibranch Pipeline Now button in the repository folder. View the logs in Scan 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.

Source: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/jenkins/plugins/git/GitTagSCMHead.java#L46-L47

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.

Source: https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java#L805.

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

Source: https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java#L75-L84

If someone could help me understand this a little better I may be able to produce the fix myself.

@ryancurrah ryancurrah added the bug label Aug 31, 2022
@KalleOlaviNiemitalo
Copy link
Contributor

Is this with Bitbucket Cloud or Bitbucket Server?

@KalleOlaviNiemitalo
Copy link
Contributor

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).

@KalleOlaviNiemitalo
Copy link
Contributor

On Bitbucket Cloud, GET /2.0/repositories/{workspace}/{repo_slug}/refs/tags/{name} returns the tagger date, too.

@ryancurrah
Copy link
Author

ryancurrah commented Sep 1, 2022

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.

@ryancurrah
Copy link
Author

Yeah it appears it's not possible in Bitbucket server without cloning.

https://community.atlassian.com/t5/Bitbucket-questions/How-to-get-the-creation-date-of-a-tag-in-BitBucket-Server/qaq-p/1277595

@ryancurrah
Copy link
Author

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.

https://jira.atlassian.com/browse/BSERV-7764

@KalleOlaviNiemitalo
Copy link
Contributor

#420 looks related, but it uses the timestamp of the Bitbucket webhook event that triggered the scan; that might not be the same as the timestamp within the Git annotated tag object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants