-
Notifications
You must be signed in to change notification settings - Fork 354
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
Replace the avatar cache beta implementation with api provided by the scm-api plugin #978
base: master
Are you sure you want to change the base?
Conversation
40ef947
to
3229937
Compare
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Fixed
Show fixed
Hide fixed
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Fixed
Show fixed
Hide fixed
a76898c
to
3eb9894
Compare
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Fixed
Show fixed
Hide fixed
10f2ea8
to
d02e956
Compare
Sorry I never found time to finish #700. Is this still work in progress? As is, this seems to be introducing a regression, i.e., none of the avatars that require athentication will be shown. |
Bitbucket server have to be developed yet (now there is a FIXME comment). Could you post the content of GET |
d02e956
to
c208872
Compare
Bitbucket Server supports avatars for projects but not for repositories. It is not possible to upload or select an avatar in the settings of a repository. |
Ok thanks, this means null is the correct value to return for repository.getAvatar method |
protected String avatar; | ||
|
||
@Override | ||
public String getAvatar() { | ||
return avatar; | ||
} |
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.
Are you expecting the API_PROJECT_PATH response from Bitbucket Server to include an "avatar" property in JSON? IIRC, that does not exist and the avatar image has to be streamed from the "avatar.png" URL (even though the image is not always in PNG format).
Perhaps it's feasible to make the plugin construct the "avatar.png" URL and make the web browser request the image from Bitbucket Server. IIRC, the default Content Security Policy of Jenkins allows embedding images from other sites. I'm however not sure the web browser will authenticate to Bitbucket in that scenario. If the user has logged out of Bitbucket, then I think the image won't be available and the resulting web page in Jenkins will be ugly.
I'm not even using the Organization Folder job type in Jenkins so I don't particularly care whether it displays the project avatar.
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.
Are you expecting the API_PROJECT_PATH response from Bitbucket Server to include an "avatar" property in JSON?
Since altassian documentation does not explain much more than "avatar String" in the response I would suppose the absolute URL or maybe a relative path.
Perhaps it's feasible to make the plugin construct the "avatar.png" URL and make the web browser request the image from Bitbucket Server.
This was my fallback, do you have an exaple of http://{baseurl}/rest/api/latest/projects/{projectKey} response? The payload test resource in stored in this repository seems to be old or trimmed so json does not contains avatar attribute at all.
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.
I don't see "avatar" property addition in the API changelog https://developer.atlassian.com/server/bitbucket/reference/api-changelog/
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.
My test Bitbucket Data Center is long gone. If I remember correctly the Project Avatar URL is a bit further down the page of the API docs that you shared https://developer.atlassian.com/server/bitbucket/rest/v815/api-group-project/#api-api-latest-projects-projectkey-avatar-png-get
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.
Bitbucket Server 7.21.0
The documentation of /rest/api/1.0/projects/{projectKey}
shows an "avatar" property in the PUT request but not in the GET response.
I tested that the GET http://{baseurl}/rest/api/1.0/projects/{projectKey}
response does not include any information about the avatar. The GET http://{baseurl}/rest/api/latest/projects/{projectKey}
response is identical. The response has only the same property names as in the example in Atlassian documentation:
{ "key": "PRJ", "id": 1, "name": "My Cool Project", "description": "The description for my cool project.", "public": true, "type": "NORMAL", "links": { "self": [ { "href": "http://link/to/project" } ] } }
Bitbucket Server 8.0.1
The documentation of GET /api/latest/projects/{projectKey}
shows the GET response as having type RestProject, which then would have an "avatar" property with type "string". I do not know whether this version can actually return an "avatar" property in the response or whether it is some kind of artifact of the document generation process. The POST /api/latest/projects
request is listed as taking both "avatar" and "avatarUrl" parameters, of which only the "avatar" parameter is described. Because the RestProject type does not include an "avatarUrl" property, it seems that Atlassian does not generate the POST /api/latest/projects
request documentation from the RestProject type, and that the mention of "avatar" in the GET response documentation is not caused by the POST request supporting "avatar".
Bitbucket Data Center 9.0.5
The documentation of GET /api/latest/projects/{projectKey}
and POST /api/latest/projects
is the same as 8.0.1 in these respects.
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.
I think to use the avatar is set otherwise self link + "/avatar.png"
2283bdf
to
1753d00
Compare
WildcardSCMHeadFilterTrait existing = (WildcardSCMHeadFilterTrait) trait; | ||
if ("*".equals(includes) && "".equals(existing.getExcludes())) { | ||
if (trait instanceof WildcardSCMHeadFilterTrait wildcardTrait) { | ||
if ("*".equals(includes) && "".equals(wildcardTrait.getExcludes())) { |
Check notice
Code scanning / CodeQL
Inefficient empty string test Note
WildcardSCMHeadFilterTrait existing = (WildcardSCMHeadFilterTrait) trait; | ||
if ("*".equals(existing.getIncludes()) && "".equals(excludes)) { | ||
if (trait instanceof WildcardSCMHeadFilterTrait wildcardTrait) { | ||
if ("*".equals(wildcardTrait.getIncludes()) && "".equals(excludes)) { |
Check notice
Code scanning / CodeQL
Inefficient empty string test Note
43c2b89
to
8ed531d
Compare
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Fixed
Show fixed
Hide fixed
8ed531d
to
b5bc56a
Compare
b5bc56a
to
75d61ea
Compare
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java
Dismissed
Show dismissed
Hide dismissed
fc52b84
to
f4196fe
Compare
612497d
to
5afcc21
Compare
edfb65d
to
5ecddfd
Compare
*/ | ||
@CheckForNull | ||
@Deprecated | ||
AvatarImage getTeamAvatar() throws IOException; |
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.
binary not compatible
5ecddfd
to
c293571
Compare
remove support for bitbucket cloud avatar image because API supports only basic authentication requests, really too limited to support them. |
src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketCloudWorkspace.java
Fixed
Show fixed
Hide fixed
c293571
to
8a6d076
Compare
…d by the scm-api plugin. There are two action that store the AvatarImage, BitbucketTeamAvatarMetadataAction and BitbucketRepoAvatarMetadataAction. The BitbucketTeamAvatarMetadataAction holds the metadata to retrieve the team/project avatar of an organization folder. The BitbucketRepoAvatarMetadataAction holds the metadata to retrieve the repository avatar of single multi branch repository. The SVG images generated by bitbucket are not supported by ImageIO, those images are replaced with Jenkins random images.
8a6d076
to
1237c9b
Compare
Replace the avatar cache beta implementation with default one provided by the scm-api plugin.
There are two action that store the AvatarImage, BitbucketTeamAvatarMetadataAction and BitbucketRepoAvatarMetadataAction.
The BitbucketTeamAvatarMetadataAction holds the metadata to retrieve the team/project avatar of an organization folder.
The BitbucketRepoAvatarMetadataAction holds the metadata to retrieve the repository avatar of single multi branch repository.
The SVG images generated by bitbucket are not supported by ImageIO, those images are replaced with Jenkins random images.
Removed the credential implementation that was serialized in each jobs/{job name}/state.xml file
In the image the first avatar is my team avatar (https://bitbucket.org/workspaces/nfalco79/avatar/?ts=1737914783)
The second image is the default avatar that bitbucket bind to Java repositories
The fourth image is the avatar of my example public repository (https://bytebucket.org/ravatar/%7B3deb8c29-778a-450c-8f69-3e50a18079df%7D?ts=3693474)
Use cases:
Cloud:
private workspace: not authenticated (https://bitbucket.org/workspaces/atlassian/avatar/?ts=1668658458)
private project: authenticated with basic authentication, token based authentication not supported by the API (https://bitbucket.org/nfalco79/workspace/projects/PRIV/avatar/32?ts=1738607808)
private repository: not authenticated (https://bytebucket.org/ravatar/%7Be5ed6221-7ed5-4852-b1fe-fc33216465ea%7D?ts=3697144)
Data Center:
NO example image
Fixes #261 and maybe #786 (description does not refer to any specific bitbucket instance ...)
Fixes JENKINS-61200