18
18
import hudson .scm .SCM ;
19
19
import hudson .security .ACL ;
20
20
import hudson .util .ListBoxModel ;
21
+ import io .jenkins .plugins .gitlabbranchsource .helpers .GitLabAvatar ;
21
22
import io .jenkins .plugins .gitlabbranchsource .helpers .GitLabLink ;
22
23
import io .jenkins .plugins .gitlabserverconfig .credentials .PersonalAccessToken ;
23
24
import io .jenkins .plugins .gitlabserverconfig .servers .GitLabServer ;
69
70
import jenkins .scm .impl .form .NamedArrayList ;
70
71
import jenkins .scm .impl .trait .Discovery ;
71
72
import jenkins .scm .impl .trait .Selection ;
73
+ import org .apache .commons .lang .StringUtils ;
72
74
import org .gitlab4j .api .Constants ;
73
75
import org .gitlab4j .api .GitLabApi ;
74
76
import org .gitlab4j .api .GitLabApiException ;
95
97
import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabHelper .commitUriTemplate ;
96
98
import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabHelper .getServerUrlFromName ;
97
99
import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabHelper .mergeRequestUriTemplate ;
98
- import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabHelper .projectUriTemplate ;
99
100
import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabHelper .splitPath ;
100
101
import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabHelper .tagUriTemplate ;
101
102
import static io .jenkins .plugins .gitlabbranchsource .helpers .GitLabIcons .ICON_GITLAB ;
@@ -186,7 +187,7 @@ public HashMap<String, AccessLevel> getMembers() {
186
187
for (Member m : gitLabApi .getProjectApi ().getAllMembers (projectPath )) {
187
188
members .put (m .getUsername (), m .getAccessLevel ());
188
189
}
189
- } catch (GitLabApiException | NoSuchFieldException e ) {
190
+ } catch (GitLabApiException e ) {
190
191
e .printStackTrace ();
191
192
return new HashMap <>();
192
193
}
@@ -267,7 +268,7 @@ protected SCMRevision retrieve(@NonNull SCMHead head, @NonNull TaskListener list
267
268
head .getClass ().getName ());
268
269
return null ;
269
270
}
270
- } catch (GitLabApiException | NoSuchFieldException e ) {
271
+ } catch (GitLabApiException e ) {
271
272
e .printStackTrace ();
272
273
}
273
274
return super .retrieve (head , listener );
@@ -507,7 +508,7 @@ public SCMSourceCriteria.Probe create(
507
508
.format ("%n%d tags were processed (query completed)%n" , count );
508
509
}
509
510
}
510
- } catch (GitLabApiException | NoSuchFieldException e ) {
511
+ } catch (GitLabApiException e ) {
511
512
e .printStackTrace ();
512
513
}
513
514
}
@@ -535,22 +536,24 @@ protected Set<String> retrieveRevisions(@NonNull TaskListener listener)
535
536
@ NonNull
536
537
@ Override
537
538
protected List <Action > retrieveActions (SCMSourceEvent event , @ NonNull TaskListener listener ) {
538
- LOGGER .info (String .format ("e, l..%s" , Thread .currentThread ().getName ()));
539
539
List <Action > result = new ArrayList <>();
540
540
if (gitlabProject == null ) {
541
541
try {
542
542
GitLabApi gitLabApi = apiBuilder (serverName );
543
543
listener .getLogger ().format ("Looking up project %s%n" , projectPath );
544
544
gitlabProject = gitLabApi .getProjectApi ().getProject (projectPath );
545
- result .add (new ObjectMetadataAction (null , gitlabProject .getDescription (),
546
- gitlabProject .getWebUrl ()));
547
- } catch (GitLabApiException | NoSuchFieldException e ) {
548
- e .printStackTrace ();
545
+ } catch (GitLabApiException e ) {
546
+ throw new IllegalStateException ("Failed to retrieve project" , e );
549
547
}
550
548
}
551
- String projectUrl = projectUriTemplate (serverName )
552
- .set ("project" , splitPath (projectPath ))
553
- .expand ();
549
+ String projectUrl = gitlabProject .getWebUrl ();
550
+ result .add (new ObjectMetadataAction (gitlabProject .getNameWithNamespace (),
551
+ gitlabProject .getDescription (),
552
+ projectUrl ));
553
+ String avatarUrl = gitlabProject .getAvatarUrl ();
554
+ if (StringUtils .isNotBlank (avatarUrl )) {
555
+ result .add (new GitLabAvatar (avatarUrl ));
556
+ }
554
557
result .add (GitLabLink .toProject (projectUrl ));
555
558
return result ;
556
559
}
@@ -565,7 +568,7 @@ protected List<Action> retrieveActions(@NonNull SCMHead head, SCMHeadEvent event
565
568
GitLabApi gitLabApi = apiBuilder (serverName );
566
569
listener .getLogger ().format ("Looking up project %s%n" , projectPath );
567
570
gitlabProject = gitLabApi .getProjectApi ().getProject (projectPath );
568
- } catch (GitLabApiException | NoSuchFieldException e ) {
571
+ } catch (GitLabApiException e ) {
569
572
e .printStackTrace ();
570
573
}
571
574
}
@@ -724,7 +727,7 @@ public SCMFile getRoot() {
724
727
return fs != null ? fs .getRoot () : null ;
725
728
}
726
729
};
727
- } catch (InterruptedException | NoSuchFieldException | GitLabApiException e ) {
730
+ } catch (InterruptedException | GitLabApiException e ) {
728
731
throw new IOException (e );
729
732
}
730
733
}
@@ -850,7 +853,7 @@ public ListBoxModel doFillProjectPathItems(@AncestorInPath SCMSourceOwner contex
850
853
}
851
854
}
852
855
return result ;
853
- } catch (GitLabApiException | NoSuchFieldException e ) {
856
+ } catch (GitLabApiException e ) {
854
857
e .printStackTrace ();
855
858
return new StandardListBoxModel ()
856
859
.includeEmptyValue ();
0 commit comments