Skip to content

Commit

Permalink
version update in ca tool projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Viji committed Jul 24, 2024
1 parent 5b936e6 commit f82238c
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/UsageDoc/CA_UsageDocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Currently LTA support is not provided for SBOM, hence until that is implemented

```
{
"CaVersion": "6.2.0",
"CaVersion": "",
"TimeOut": 200,
"ProjectType": "<Insert ProjectType>",
"SW360ProjectName": "<Insert SW360 Project Name>",
Expand Down
1 change: 1 addition & 0 deletions src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>ArtifactoryUploader</AssemblyName>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
13 changes: 13 additions & 0 deletions src/ArtifactoryUploader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using LCT.Common.Model;

namespace ArtifactoryUploader
{
Expand All @@ -44,6 +45,7 @@ static async Task Main(string[] args)
string FolderPath = InitiateLogger(appSettings);

settingsManager.CheckRequiredArgsToRun(appSettings, "Uploader");
CatoolInfo caToolVersion = GetCatoolVersionFromProjectfile();

Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Artifactory Uploader >>>>>====================", null);
Logger.Logger.Log(null, Level.Notice, $"\nStart of Artifactory Uploader execution: {DateTime.Now}", null);
Expand All @@ -55,6 +57,8 @@ static async Task Main(string[] args)

Logger.Logger.Log(null, Level.Info, $"Input Parameters used in Artifactory Uploader:\n\t", null);
Logger.Logger.Log(null, Level.Notice, $"\tBomFilePath:\t\t {appSettings.BomFilePath}\n\t" +
$"CaToolVersion\t\t --> {caToolVersion.CatoolVersion}\n\t" +
$"CaToolRunningPath\t --> {caToolVersion.CatoolRunningLocation}\n\t" +
$"JFrogUrl:\t\t {appSettings.JFrogApi}\n\t" +
$"Release:\t\t {appSettings.Release}\n\t" +
$"LogFolderPath:\t\t {Path.GetFullPath(FolderPath)}\n", null);
Expand All @@ -77,6 +81,15 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Notice, $"End of Artifactory Uploader execution : {DateTime.Now}\n", null);
}

private static CatoolInfo GetCatoolVersionFromProjectfile()
{
CatoolInfo catoolInfo = new CatoolInfo();
var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version;
catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}";
catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
return catoolInfo;
}

private static string InitiateLogger(CommonAppSettings appSettings)
{
string FolderPath;
Expand Down
1 change: 1 addition & 0 deletions src/LCT.APICommunications/LCT.APICommunications.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
1 change: 1 addition & 0 deletions src/LCT.Common/LCT.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
16 changes: 16 additions & 0 deletions src/LCT.Common/Model/CatoolInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// --------------------------------------------------------------------------------------------------------------------
// SPDX-FileCopyrightText: 2024 Siemens AG
//
// SPDX-License-Identifier: MIT
// --------------------------------------------------------------------------------------------------------------------


namespace LCT.Common.Model
{
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class CatoolInfo
{
public string CatoolVersion { get; set; }
public string CatoolRunningLocation { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/LCT.Common/appSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// --------------------------------------------------------------------------------------------------------------------

{
"CaVersion": "7.0.0",
"CaVersion": "",
"TimeOut": 200,
"ProjectType": "<Insert ProjectType>",
"SW360ProjectName": "<Insert SW360 Project Name>",
Expand Down
1 change: 1 addition & 0 deletions src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
1 change: 1 addition & 0 deletions src/LCT.Facade/LCT.Facade.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
8 changes: 5 additions & 3 deletions src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public void SetMetadataInComparisonBOM_GivenBOMWithEmptyMetadata_FillsInMetadata
{
CaVersion = "1.2.3"
};
CatoolInfo caToolInformation = new CatoolInfo() { CatoolVersion = "6.0.0", CatoolRunningLocation="" };
//Act
Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases);
Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation);

//Assert
Assert.That(2, Is.EqualTo(files.Metadata.Tools.Count), "Returns bom with metadata ");
Expand Down Expand Up @@ -92,9 +93,10 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI
Version = projectReleases.Version,
Type = Component.Classification.Application
};


CatoolInfo caToolInformation = new CatoolInfo() { CatoolVersion = "6.0.0", CatoolRunningLocation = "" };
//Act
Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases);
Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation);

//Assert
Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata tools");
Expand Down
13 changes: 10 additions & 3 deletions src/LCT.PackageIdentifier/BomCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
using LCT.Common;
using LCT.Common.Constants;
using LCT.Common.Interface;
using LCT.Common.Model;
using LCT.PackageIdentifier.Interface;
using LCT.PackageIdentifier.Model;
using LCT.Services.Interface;
using log4net;
using log4net.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
Expand All @@ -42,7 +42,11 @@ public BomCreator(ICycloneDXBomParser cycloneDXBomParser)
CycloneDXBomParser = cycloneDXBomParser;
}

public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases)
public async Task GenerateBom(CommonAppSettings appSettings,
IBomHelper bomHelper,
IFileOperations fileOperations,
ProjectReleases projectReleases,
CatoolInfo caToolInformation)
{
Logger.Debug($"GenerateBom():Start");
Bom listOfComponentsToBom;
Expand All @@ -56,7 +60,10 @@ public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelpe
//Get project details for metadata properties

//sets metadata properties
listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings, projectReleases);
listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom,
appSettings,
projectReleases,
caToolInformation);

// Writes Comparison Bom
Logger.Logger.Log(null, Level.Notice, $"Writing CycloneDX BOM..", null);
Expand Down
8 changes: 6 additions & 2 deletions src/LCT.PackageIdentifier/CycloneBomProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using LCT.APICommunications.Model;
using LCT.Common;
using LCT.Common.Constants;
using LCT.Common.Model;
using log4net;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -19,7 +20,10 @@ public static class CycloneBomProcessor

private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSettings, ProjectReleases projectReleases)
public static Bom SetMetadataInComparisonBOM(Bom bom,
CommonAppSettings appSettings,
ProjectReleases projectReleases,
CatoolInfo caToolInformation)
{
Logger.Debug("Starting to add metadata info into the BOM");
List<Tool> tools = new List<Tool>();
Expand All @@ -28,7 +32,7 @@ public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSetti
Tool tool = new Tool
{
Name = "Clearing Automation Tool",
Version = appSettings.CaVersion,
Version = caToolInformation.CatoolVersion,
Vendor = "Siemens AG",
ExternalReferences = new List<ExternalReference>() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } }

Expand Down
4 changes: 3 additions & 1 deletion src/LCT.PackageIdentifier/Interface/IBomCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using LCT.APICommunications.Model;
using LCT.Common;
using LCT.Common.Interface;
using LCT.Common.Model;
using LCT.Services.Interface;
using System.Threading.Tasks;

Expand All @@ -21,7 +22,8 @@ public interface IBomCreator

public IBomHelper BomHelper { get; set; }

public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases);
public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations,
ProjectReleases projectReleases, CatoolInfo caToolInformation);

public Task<bool> CheckJFrogConnection();
}
Expand Down
1 change: 1 addition & 0 deletions src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>PackageIdentifier</AssemblyName>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
15 changes: 14 additions & 1 deletion src/LCT.PackageIdentifier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static async Task Main(string[] args)
ProjectReleases projectReleases = new ProjectReleases();
string FolderPath = LogFolderInitialisation(appSettings);

CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile();
settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer");

Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package Identifier >>>>>====================", null);
Expand All @@ -78,6 +79,8 @@ static async Task Main(string[] args)
}

Logger.Logger.Log(null, Level.Notice, $"Input Parameters used in Package Identifier:\n\t" +
$"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" +
$"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" +
$"PackageFilePath\t\t --> {appSettings.PackageFilePath}\n\t" +
$"BomFolderPath\t\t --> {appSettings.BomFolderPath}\n\t" +
$"SBOMTemplateFilePath\t --> {appSettings.CycloneDxSBomTemplatePath}\n\t" +
Expand All @@ -104,11 +107,21 @@ static async Task Main(string[] args)
//Validating JFrog Settings
if (await bomCreator.CheckJFrogConnection())
{
await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(),projectReleases);
await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(), projectReleases,
caToolInformation);
}
Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null);
}

private static CatoolInfo GetCatoolVersionFromProjectfile()
{
CatoolInfo catoolInfo = new CatoolInfo();
var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version;
catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}";
catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
return catoolInfo;
}

private static IJFrogService GetJfrogService(CommonAppSettings appSettings)
{
ArtifactoryCredentials artifactoryUpload = new ArtifactoryCredentials()
Expand Down
1 change: 1 addition & 0 deletions src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>SW360PackageCreator</AssemblyName>
<Version>7.0.0</Version>
<RootNamespace>LCT.SW360PackageCreator</RootNamespace>
</PropertyGroup>

Expand Down
12 changes: 12 additions & 0 deletions src/LCT.SW360PackageCreator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static async Task Main(string[] args)
string FolderPath = InitiateLogger(appSettings);
settingsManager.CheckRequiredArgsToRun(appSettings, "Creator");
await CreatorValidator.ValidateAppSettings(appSettings, sw360ProjectService, projectReleases);
CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile();

Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package creator >>>>>====================", null);
Logger.Logger.Log(null, Level.Notice, $"\nStart of Package creator execution : {DateTime.Now}", null);
Expand All @@ -62,6 +63,8 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Alert, $"Package creator is running in TEST mode \n", null);

Logger.Logger.Log(null, Level.Notice, $"Input parameters used in Package Creator:\n\t" +
$"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" +
$"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" +
$"BomFilePath\t\t --> {appSettings.BomFilePath}\n\t" +
$"SW360Url\t\t --> {appSettings.SW360URL}\n\t" +
$"SW360AuthTokenType\t --> {appSettings.SW360AuthTokenType}\n\t" +
Expand All @@ -79,6 +82,15 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Notice, $"End of Package Creator execution: {DateTime.Now}\n", null);
}

private static CatoolInfo GetCatoolVersionFromProjectfile()
{
CatoolInfo catoolInfo = new CatoolInfo();
var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version;
catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}";
catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
return catoolInfo;
}

private static ISw360ProjectService Getsw360ProjectServiceObject(CommonAppSettings appSettings, out ISW360ApicommunicationFacade sW360ApicommunicationFacade)
{
ISw360ProjectService sw360ProjectService;
Expand Down
1 change: 1 addition & 0 deletions src/LCT.Services/LCT.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Version>7.0.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down

0 comments on commit f82238c

Please sign in to comment.