Skip to content

Commit

Permalink
Displays the repository avatar in Jenkins (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Lauris BH <lauris@nix.lv>
  • Loading branch information
kins-dev and lafriks authored Apr 29, 2022
1 parent 88a1ac7 commit e0817df
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"gitea",
"repos"
]
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ This plugin provides the Jenkins integrations for [Gitea](https://gitea.io).
For details on the plugin see [plugins.jenkins.io/gitea](https://plugins.jenkins.io/gitea).

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

Build using something like:

```bash
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/"
export MAVEN_HOME="/opt/apache-maven-3.8.4/"
"${MAVEN_HOME}/bin/mvn" package
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/jenkinsci/plugin/gitea/GiteaSCMSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ protected List<Action> retrieveActions(SCMSourceEvent event, @NonNull TaskListen
}
}
List<Action> result = new ArrayList<>();
result.add(new ObjectMetadataAction(null, giteaRepository.getDescription(), giteaRepository.getWebsite()));
result.add(new ObjectMetadataAction(giteaRepository.getName(), giteaRepository.getDescription(), giteaRepository.getWebsite()));
if (StringUtils.isNotBlank(giteaRepository.getAvatarUrl())) {
result.add(new GiteaAvatar(giteaRepository.getAvatarUrl()));
}
result.add(new GiteaLink("icon-gitea-repo", UriTemplate.buildFromTemplate(serverUrl)
.path(UriTemplateBuilder.var("owner"))
.path(UriTemplateBuilder.var("repository"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class GiteaRepository extends GiteaObject<GiteaRepository> {
private String defaultBranch;
private Date createdAt;
private Date updatedAt;
private String avatarUrl;
private Permissions permissions;

public GiteaRepository() {
Expand All @@ -63,7 +64,7 @@ public GiteaRepository(GiteaOwner owner, GiteaRepository parent, String name, St
String description, boolean _private, boolean fork, boolean empty, boolean mirror, boolean archived,
String htmlUrl, String sshUrl, String cloneUrl, String website, long starsCount,
long forksCount,
long watchersCount, long openIssuesCount, String defaultBranch,
long watchersCount, long openIssuesCount, String defaultBranch, String avatarUrl,
Permissions permissions) {
this.owner = owner;
this.parent = parent;
Expand All @@ -84,6 +85,7 @@ public GiteaRepository(GiteaOwner owner, GiteaRepository parent, String name, St
this.watchersCount = watchersCount;
this.openIssuesCount = openIssuesCount;
this.defaultBranch = defaultBranch;
this.avatarUrl = avatarUrl;
this.permissions = permissions;
}

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

public String getAvatarUrl() {
return avatarUrl;
}

@JsonProperty("avatar_url")
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}

public Permissions getPermissions() {
return permissions == null ? null : permissions.clone();
}
Expand Down Expand Up @@ -303,6 +314,7 @@ public String toString() {
", watchersCount=" + watchersCount +
", openIssuesCount=" + openIssuesCount +
", defaultBranch='" + defaultBranch + '\'' +
", avatarUrl='" + avatarUrl + '\'' +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
", permissions=" + permissions +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,16 @@ public List<GiteaRepository> fetchRepositories(String username) throws IOExcepti

@Override
public List<GiteaRepository> fetchRepositories(GiteaOwner owner) throws IOException, InterruptedException {
if(owner instanceof GiteaOrganization) {
if (owner instanceof GiteaOrganization) {
return fetchOrganizationRepositories(owner);
}
return fetchRepositories(owner.getUsername());

}

@Override
public List<GiteaRepository> fetchOrganizationRepositories(GiteaOwner owner) throws IOException, InterruptedException {
public List<GiteaRepository> fetchOrganizationRepositories(GiteaOwner owner)
throws IOException, InterruptedException {
return getList(
api()
.literal("/orgs")
Expand Down Expand Up @@ -322,7 +323,8 @@ public GiteaAnnotatedTag fetchAnnotatedTag(String username, String repository, S
}

@Override
public GiteaAnnotatedTag fetchAnnotatedTag(GiteaRepository repository, GiteaTag tag) throws IOException, InterruptedException {
public GiteaAnnotatedTag fetchAnnotatedTag(GiteaRepository repository, GiteaTag tag)
throws IOException, InterruptedException {
return fetchAnnotatedTag(repository.getOwner().getUsername(), repository.getName(), tag.getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void reset() {
null, "", "", "",
true, false, false, false, false,
"", "", "", "",
0L, 0L, 0L, 0L, "",
0L, 0L, 0L, 0L, "", "",
null
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void reset() {
null, "", "", "",
true, false, false, false, false,
"", "", "", "",
0L, 0L, 0L, 0L, "",
0L, 0L, 0L, 0L, "", "",
null
);
}
Expand Down

0 comments on commit e0817df

Please sign in to comment.