@@ -43,35 +43,8 @@ public static List<Component> RemoveExcludedComponents(List<Component> Component
4343 List < string > ExcludedComponentsFromPurl = ExcludedComponents ? . Where ( ec => ec . StartsWith ( "pkg:" ) ) . ToList ( ) ;
4444 List < string > otherExcludedComponents = ExcludedComponents ? . Where ( ec => ! ec . StartsWith ( "pkg:" ) ) . ToList ( ) ;
4545
46- foreach ( string excludedComponent in ExcludedComponentsFromPurl )
47- {
48- foreach ( var component in ComponentList )
49- {
50- if ( component . Purl != null && component . Purl . Equals ( excludedComponent , StringComparison . OrdinalIgnoreCase ) )
51- {
52- noOfExcludedComponents ++ ;
53- ExcludedList . Add ( component ) ;
54- }
55- }
56- }
57- foreach ( string excludedComponent in otherExcludedComponents )
58- {
59- string [ ] excludedcomponent = excludedComponent . ToLower ( ) . Split ( ':' ) ;
60- foreach ( var component in ComponentList )
61- {
62- string name = component . Name ;
63- if ( ! string . IsNullOrEmpty ( component . Group ) && ( component . Group != component . Name ) )
64- {
65- name = $ "{ component . Group } /{ component . Name } ";
66- }
67- if ( excludedcomponent . Length > 0 && ( Regex . IsMatch ( name . ToLowerInvariant ( ) , WildcardToRegex ( excludedcomponent [ 0 ] . ToLowerInvariant ( ) ) ) ) &&
68- ( component . Version . ToLowerInvariant ( ) . Contains ( excludedcomponent [ 1 ] . ToLowerInvariant ( ) ) || excludedcomponent [ 1 ] . ToLowerInvariant ( ) == "*" ) )
69- {
70- noOfExcludedComponents ++ ;
71- ExcludedList . Add ( component ) ;
72- }
73- }
74- }
46+ ExcludedList . AddRange ( RemoveExcludedComponentsFromPurl ( ComponentList , ExcludedComponentsFromPurl , ref noOfExcludedComponents ) ) ;
47+ ExcludedList . AddRange ( RemoveOtherExcludedComponents ( ComponentList , otherExcludedComponents , ref noOfExcludedComponents ) ) ;
7548 ComponentList . RemoveAll ( item => ExcludedList . Contains ( item ) ) ;
7649 return ComponentList ;
7750 }
@@ -302,6 +275,59 @@ public static void PublishFilesToArtifact()
302275 artifactPublisher . UploadLogs ( ) ;
303276 artifactPublisher . UploadBom ( ) ;
304277 }
278+ public static string [ ] GetRepoList ( CommonAppSettings appSettings )
279+ {
280+ string [ ] repoList = null ;
281+
282+ if ( appSettings . ProjectType . Equals ( "CONAN" , StringComparison . InvariantCultureIgnoreCase ) )
283+ {
284+ repoList = ( appSettings . Conan ? . Artifactory . InternalRepos ?? Array . Empty < string > ( ) )
285+ . Concat ( appSettings . Conan ? . Artifactory . DevRepos ?? Array . Empty < string > ( ) )
286+ . Concat ( appSettings . Conan ? . Artifactory . RemoteRepos ?? Array . Empty < string > ( ) )
287+ . Concat ( appSettings . Conan ? . Artifactory . ThirdPartyRepos ? . Select ( repo => repo . Name ) ?? Array . Empty < string > ( ) )
288+ . ToArray ( ) ;
289+ } else if ( appSettings . ProjectType . Equals ( "NPM" , StringComparison . InvariantCultureIgnoreCase ) )
290+ {
291+ repoList = ( appSettings . Npm ? . Artifactory . InternalRepos ?? Array . Empty < string > ( ) )
292+ . Concat ( appSettings . Npm ? . Artifactory . DevRepos ?? Array . Empty < string > ( ) )
293+ . Concat ( appSettings . Npm ? . Artifactory . RemoteRepos ?? Array . Empty < string > ( ) )
294+ . Concat ( appSettings . Npm ? . Artifactory . ThirdPartyRepos ? . Select ( repo => repo . Name ) ?? Array . Empty < string > ( ) )
295+ . ToArray ( ) ;
296+ }
297+ else if ( appSettings . ProjectType . Equals ( "NUGET" , StringComparison . InvariantCultureIgnoreCase ) )
298+ {
299+ repoList = ( appSettings . Nuget ? . Artifactory . InternalRepos ?? Array . Empty < string > ( ) )
300+ . Concat ( appSettings . Nuget ? . Artifactory . DevRepos ?? Array . Empty < string > ( ) )
301+ . Concat ( appSettings . Nuget ? . Artifactory . RemoteRepos ?? Array . Empty < string > ( ) )
302+ . Concat ( appSettings . Nuget ? . Artifactory . ThirdPartyRepos ? . Select ( repo => repo . Name ) ?? Array . Empty < string > ( ) )
303+ . ToArray ( ) ;
304+ }
305+ else if ( appSettings . ProjectType . Equals ( "POETRY" , StringComparison . InvariantCultureIgnoreCase ) )
306+ {
307+ repoList = ( appSettings . Poetry ? . Artifactory . InternalRepos ?? Array . Empty < string > ( ) )
308+ . Concat ( appSettings . Poetry ? . Artifactory . DevRepos ?? Array . Empty < string > ( ) )
309+ . Concat ( appSettings . Poetry ? . Artifactory . RemoteRepos ?? Array . Empty < string > ( ) )
310+ . Concat ( appSettings . Poetry ? . Artifactory . ThirdPartyRepos ? . Select ( repo => repo . Name ) ?? Array . Empty < string > ( ) )
311+ . ToArray ( ) ;
312+ }
313+ else if ( appSettings . ProjectType . Equals ( "DEBIAN" , StringComparison . InvariantCultureIgnoreCase ) )
314+ {
315+ repoList = ( appSettings . Debian ? . Artifactory . InternalRepos ?? Array . Empty < string > ( ) )
316+ . Concat ( appSettings . Debian ? . Artifactory . DevRepos ?? Array . Empty < string > ( ) )
317+ . Concat ( appSettings . Debian ? . Artifactory . RemoteRepos ?? Array . Empty < string > ( ) )
318+ . Concat ( appSettings . Debian ? . Artifactory . ThirdPartyRepos ? . Select ( repo => repo . Name ) ?? Array . Empty < string > ( ) )
319+ . ToArray ( ) ;
320+ }
321+ else if ( appSettings . ProjectType . Equals ( "MAVEN" , StringComparison . InvariantCultureIgnoreCase ) )
322+ {
323+ repoList = ( appSettings . Maven ? . Artifactory . InternalRepos ?? Array . Empty < string > ( ) )
324+ . Concat ( appSettings . Maven ? . Artifactory . DevRepos ?? Array . Empty < string > ( ) )
325+ . Concat ( appSettings . Maven ? . Artifactory . RemoteRepos ?? Array . Empty < string > ( ) )
326+ . Concat ( appSettings . Maven ? . Artifactory . ThirdPartyRepos ? . Select ( repo => repo . Name ) ?? Array . Empty < string > ( ) )
327+ . ToArray ( ) ;
328+ }
329+ return repoList ;
330+ }
305331
306332 #endregion
307333
@@ -316,6 +342,50 @@ private static string Sw360URL(string sw360Env, string releaseId)
316342 string sw360URL = $ "{ sw360Env } { "/group/guest/components/-/component/release/detailRelease/" } { releaseId } ";
317343 return sw360URL ;
318344 }
345+ private static List < Component > RemoveExcludedComponentsFromPurl ( List < Component > ComponentList , List < string > ExcludedComponentsFromPurl , ref int noOfExcludedComponents )
346+ {
347+ List < Component > ExcludedList = new List < Component > ( ) ;
348+
349+ foreach ( string excludedComponent in ExcludedComponentsFromPurl )
350+ {
351+ foreach ( var component in ComponentList )
352+ {
353+ if ( component . Purl != null && component . Purl . Equals ( excludedComponent , StringComparison . OrdinalIgnoreCase ) )
354+ {
355+ noOfExcludedComponents ++ ;
356+ ExcludedList . Add ( component ) ;
357+ }
358+ }
359+ }
360+
361+ return ExcludedList ;
362+ }
363+
364+ private static List < Component > RemoveOtherExcludedComponents ( List < Component > ComponentList , List < string > otherExcludedComponents , ref int noOfExcludedComponents )
365+ {
366+ List < Component > ExcludedList = new List < Component > ( ) ;
367+
368+ foreach ( string excludedComponent in otherExcludedComponents )
369+ {
370+ string [ ] excludedcomponent = excludedComponent . ToLower ( ) . Split ( ':' ) ;
371+ foreach ( var component in ComponentList )
372+ {
373+ string name = component . Name ;
374+ if ( ! string . IsNullOrEmpty ( component . Group ) && ( component . Group != component . Name ) )
375+ {
376+ name = $ "{ component . Group } /{ component . Name } ";
377+ }
378+ if ( excludedcomponent . Length > 0 && ( Regex . IsMatch ( name . ToLowerInvariant ( ) , WildcardToRegex ( excludedcomponent [ 0 ] . ToLowerInvariant ( ) ) ) ) &&
379+ ( component . Version . ToLowerInvariant ( ) . Contains ( excludedcomponent [ 1 ] . ToLowerInvariant ( ) ) || excludedcomponent [ 1 ] . ToLowerInvariant ( ) == "*" ) )
380+ {
381+ noOfExcludedComponents ++ ;
382+ ExcludedList . Add ( component ) ;
383+ }
384+ }
385+ }
386+
387+ return ExcludedList ;
388+ }
319389 #endregion
320390 }
321391}
0 commit comments