Skip to content

Commit e0817df

Browse files
kins-devlafriks
andauthored
Displays the repository avatar in Jenkins (#49)
Co-authored-by: Lauris BH <[email protected]>
1 parent 88a1ac7 commit e0817df

File tree

8 files changed

+39
-8
lines changed

8 files changed

+39
-8
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cSpell.words": [
3+
"gitea",
4+
"repos"
5+
]
6+
}

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ This plugin provides the Jenkins integrations for [Gitea](https://gitea.io).
99
For details on the plugin see [plugins.jenkins.io/gitea](https://plugins.jenkins.io/gitea).
1010

1111
For open issues on the plugin see [the Jenkins JIRA under component `gitea-plugin`](https://issues.jenkins-ci.org/issues/?jql=status%20in%20(Untriaged%2C%20Open%2C%20%22In%20Progress%22%2C%20Reopened%2C%20%22To%20Do%22)%20AND%20component%20%3D%20gitea-plugin).
12+
13+
Build using something like:
14+
15+
```bash
16+
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"
17+
export MAVEN_HOME="/opt/apache-maven-3.8.4/"
18+
"${MAVEN_HOME}/bin/mvn" package
19+
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<licenses>
2020
<license>
2121
<name>MIT</name>
22-
<url>http://opensource.org/licenses/MIT</url>
22+
<url>https://opensource.org/licenses/MIT</url>
2323
</license>
2424
</licenses>
2525

src/main/java/org/jenkinsci/plugin/gitea/GiteaSCMSource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,10 @@ protected List<Action> retrieveActions(SCMSourceEvent event, @NonNull TaskListen
465465
}
466466
}
467467
List<Action> result = new ArrayList<>();
468-
result.add(new ObjectMetadataAction(null, giteaRepository.getDescription(), giteaRepository.getWebsite()));
468+
result.add(new ObjectMetadataAction(giteaRepository.getName(), giteaRepository.getDescription(), giteaRepository.getWebsite()));
469+
if (StringUtils.isNotBlank(giteaRepository.getAvatarUrl())) {
470+
result.add(new GiteaAvatar(giteaRepository.getAvatarUrl()));
471+
}
469472
result.add(new GiteaLink("icon-gitea-repo", UriTemplate.buildFromTemplate(serverUrl)
470473
.path(UriTemplateBuilder.var("owner"))
471474
.path(UriTemplateBuilder.var("repository"))

src/main/java/org/jenkinsci/plugin/gitea/client/api/GiteaRepository.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class GiteaRepository extends GiteaObject<GiteaRepository> {
5454
private String defaultBranch;
5555
private Date createdAt;
5656
private Date updatedAt;
57+
private String avatarUrl;
5758
private Permissions permissions;
5859

5960
public GiteaRepository() {
@@ -63,7 +64,7 @@ public GiteaRepository(GiteaOwner owner, GiteaRepository parent, String name, St
6364
String description, boolean _private, boolean fork, boolean empty, boolean mirror, boolean archived,
6465
String htmlUrl, String sshUrl, String cloneUrl, String website, long starsCount,
6566
long forksCount,
66-
long watchersCount, long openIssuesCount, String defaultBranch,
67+
long watchersCount, long openIssuesCount, String defaultBranch, String avatarUrl,
6768
Permissions permissions) {
6869
this.owner = owner;
6970
this.parent = parent;
@@ -84,6 +85,7 @@ public GiteaRepository(GiteaOwner owner, GiteaRepository parent, String name, St
8485
this.watchersCount = watchersCount;
8586
this.openIssuesCount = openIssuesCount;
8687
this.defaultBranch = defaultBranch;
88+
this.avatarUrl = avatarUrl;
8789
this.permissions = permissions;
8890
}
8991

@@ -274,6 +276,15 @@ public void setUpdatedAt(Date updatedAt) {
274276
this.updatedAt = updatedAt == null ? null : (Date) updatedAt.clone();
275277
}
276278

279+
public String getAvatarUrl() {
280+
return avatarUrl;
281+
}
282+
283+
@JsonProperty("avatar_url")
284+
public void setAvatarUrl(String avatarUrl) {
285+
this.avatarUrl = avatarUrl;
286+
}
287+
277288
public Permissions getPermissions() {
278289
return permissions == null ? null : permissions.clone();
279290
}
@@ -303,6 +314,7 @@ public String toString() {
303314
", watchersCount=" + watchersCount +
304315
", openIssuesCount=" + openIssuesCount +
305316
", defaultBranch='" + defaultBranch + '\'' +
317+
", avatarUrl='" + avatarUrl + '\'' +
306318
", createdAt=" + createdAt +
307319
", updatedAt=" + updatedAt +
308320
", permissions=" + permissions +

src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,16 @@ public List<GiteaRepository> fetchRepositories(String username) throws IOExcepti
240240

241241
@Override
242242
public List<GiteaRepository> fetchRepositories(GiteaOwner owner) throws IOException, InterruptedException {
243-
if(owner instanceof GiteaOrganization) {
243+
if (owner instanceof GiteaOrganization) {
244244
return fetchOrganizationRepositories(owner);
245245
}
246246
return fetchRepositories(owner.getUsername());
247247

248248
}
249249

250250
@Override
251-
public List<GiteaRepository> fetchOrganizationRepositories(GiteaOwner owner) throws IOException, InterruptedException {
251+
public List<GiteaRepository> fetchOrganizationRepositories(GiteaOwner owner)
252+
throws IOException, InterruptedException {
252253
return getList(
253254
api()
254255
.literal("/orgs")
@@ -322,7 +323,8 @@ public GiteaAnnotatedTag fetchAnnotatedTag(String username, String repository, S
322323
}
323324

324325
@Override
325-
public GiteaAnnotatedTag fetchAnnotatedTag(GiteaRepository repository, GiteaTag tag) throws IOException, InterruptedException {
326+
public GiteaAnnotatedTag fetchAnnotatedTag(GiteaRepository repository, GiteaTag tag)
327+
throws IOException, InterruptedException {
326328
return fetchAnnotatedTag(repository.getOwner().getUsername(), repository.getName(), tag.getId());
327329
}
328330

src/test/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void reset() {
3030
null, "", "", "",
3131
true, false, false, false, false,
3232
"", "", "", "",
33-
0L, 0L, 0L, 0L, "",
33+
0L, 0L, 0L, 0L, "", "",
3434
null
3535
);
3636
}

src/test/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection_PagedRequests_Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void reset() {
3333
null, "", "", "",
3434
true, false, false, false, false,
3535
"", "", "", "",
36-
0L, 0L, 0L, 0L, "",
36+
0L, 0L, 0L, 0L, "", "",
3737
null
3838
);
3939
}

0 commit comments

Comments
 (0)