From f1c46e9fc4b77191aaee4f2aebf3bc4b3038631a Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:25:45 -0500 Subject: [PATCH 01/13] Delete Jenkinsfile --- Jenkinsfile | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index c97ee2a..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,44 +0,0 @@ -pipeline { - agent any - options { - // This is required if you want to clean before build with the "Workspace Cleanup Plugin" - skipDefaultCheckout(true) - } - stages { - stage('SCM') { - steps { - // Clean before build using the "Workspace Cleanup Plugin" - cleanWs() - checkout scm - } - } - - stage('Download Build Wrapper') { - steps { - powershell ''' - $path = ".sonar/build-wrapper-win-x86.zip" - New-Item -ItemType directory -Path .sonar -Force - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile("https://ke100.ngrok.io/static/cpp/build-wrapper-win-x86.zip", $path) - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($path, ".sonar") - $env:Path += ";.sonar/build-wrapper-win-x86" - ''' - } - } - - stage('SonarQube Analysis and Build') { - steps { - script { - def msbuildHome = tool 'MSBuild'; // MSBuild from VS 2022 - def scannerHome = tool 'SonarScanner for MSBuild'; // Name of the SonarQube Scanner you created in "Global Tool Configuration" section - withSonarQubeEnv('KESQ10') { - bat "dotnet ${scannerHome}\\SonarScanner.MSBuild.dll begin /k:\"kiloecho-sonar_cppAndcSharp_AYgqQyx_BphOJVwWroRs\" /d:\"sonar.cfamily.build-wrapper-output=wrapper-output\" /d:sonar.verbose=true" - powershell "build-wrapper-win-x86-64.exe --out-dir wrapper-output ${msbuildHome} ./CPlusPlusAndCSharp.sln /t:Rebuild /nodeReuse:False /restore" - bat "dotnet ${scannerHome}\\SonarScanner.MSBuild.dll end" - } - } - } - } - } -} From e6d2d21daef0e73dccac6d5b19dadc2973876b6d Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:26:30 -0500 Subject: [PATCH 02/13] Update build.yml --- .github/workflows/build.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5adf675..1affdc2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,30 +1,29 @@ -name: Build - +name: SonarQube on: push: branches: - main pull_request: types: [opened, synchronize, reopened] - jobs: build: name: Build and analyze - runs-on: windows-latest - + runs-on: ubuntu-latest + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - uses: SonarSource/sonarqube-scan-action@v4 + - name: Install Build Wrapper + uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 + - name: Run Build Wrapper + run: | + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - # If you wish to fail your job when the Quality Gate is red, uncomment the - # following lines. This would typically be used to fail a deployment. - # We do not recommend to use this in a pull request. Prefer using pull request - # decoration instead. - # - uses: SonarSource/sonarqube-quality-gate-action@v1 - # timeout-minutes: 5 - # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" From bd5cb7cb2bd109302bf7ff09fc6355235b32d197 Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:38:04 -0500 Subject: [PATCH 03/13] Update build.yml --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1affdc2..cd7c60c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,19 +11,37 @@ jobs: runs-on: ubuntu-latest env: BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + SONAR_SCANNER_PROJECT_KEY: SupportTeam-SC-demos_kilo-cppAndcSharp steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 + + - name: Install .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Install SonarScanner for .NET + run: dotnet tool install --global dotnet-sonarscanner + - name: Install Build Wrapper uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 - - name: Run Build Wrapper + + - name: SonarScanner for .NET - Begin + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} - - name: SonarQube Scan - uses: SonarSource/sonarqube-scan-action@v5 + dotnet-sonarscanner begin \ + /k:"${{ env.SONAR_SCANNER_PROJECT_KEY }}" \ + /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ + /d:sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + + - name: Build Solution with Build Wrapper + run: | + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} dotnet build CPlusPlusAndCSharp.sln --no-incremental + + - name: SonarScanner for .NET - End env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: > - --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" + run: dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From d4fc06050c205820e28e6b05029272ee5a227642 Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:38:32 -0500 Subject: [PATCH 04/13] Update sonar-project.properties --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index b24cc20..88148ab 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1 +1 @@ -sonar.projectKey=kiloecho-sonar_cppAndcSharp_31bc1e05-0358-4305-993a-c4367ca5a954 +sonar.projectKey=SupportTeam-SC-demos_kilo-cppAndcSharp From 9eef10f9e34b255c84c2cf6a45fea8558a77205f Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:39:23 -0500 Subject: [PATCH 05/13] Update sonar-project.properties --- sonar-project.properties | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index 88148ab..5642ed5 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1 +1,14 @@ sonar.projectKey=SupportTeam-SC-demos_kilo-cppAndcSharp +sonar.organization=supportteam-sc-demos + + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=kilo-cppAndcSharp +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From a881beb688750336697b65af60648a4c63ddaf85 Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:40:30 -0500 Subject: [PATCH 06/13] Update CPlusPlusAndCSharp.cpp --- CPlusPlusAndCSharp/CPlusPlusAndCSharp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CPlusPlusAndCSharp/CPlusPlusAndCSharp.cpp b/CPlusPlusAndCSharp/CPlusPlusAndCSharp.cpp index ecfcff3..32dd028 100644 --- a/CPlusPlusAndCSharp/CPlusPlusAndCSharp.cpp +++ b/CPlusPlusAndCSharp/CPlusPlusAndCSharp.cpp @@ -30,3 +30,5 @@ void f() // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file + +// Triggering Actions From 7cc9eb5cd825a4c0cfdb9b5eedfc7226f1edd453 Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:48:47 -0500 Subject: [PATCH 07/13] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd7c60c..d09ddfb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,7 @@ jobs: run: | dotnet-sonarscanner begin \ /k:"${{ env.SONAR_SCANNER_PROJECT_KEY }}" \ + /o: "supportteam-sc-demos" \ /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ /d:sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" From 70a12857fee13f5c509eb08e08c6974cf4ca14a4 Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:50:16 -0500 Subject: [PATCH 08/13] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d09ddfb..4a57c38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: run: | dotnet-sonarscanner begin \ /k:"${{ env.SONAR_SCANNER_PROJECT_KEY }}" \ - /o: "supportteam-sc-demos" \ + /o:"supportteam-sc-demos" \ /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ /d:sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" From d0c17d1b66e1127801af435e2c415f13fa104c0b Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:53:54 -0500 Subject: [PATCH 09/13] Update build.yml to build on Windows Got an error when trying to build on linux --- .github/workflows/build.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a57c38..b86f05e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,9 @@ on: jobs: build: name: Build and analyze - runs-on: ubuntu-latest + runs-on: windows-latest # <-- Changed from ubuntu-latest to windows-latest env: - BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory SONAR_SCANNER_PROJECT_KEY: SupportTeam-SC-demos_kilo-cppAndcSharp steps: - uses: actions/checkout@v4 @@ -32,15 +32,19 @@ jobs: env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - dotnet-sonarscanner begin \ - /k:"${{ env.SONAR_SCANNER_PROJECT_KEY }}" \ - /o:"supportteam-sc-demos" \ - /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ + dotnet-sonarscanner begin ` + /k:"${{ env.SONAR_SCANNER_PROJECT_KEY }}" ` + /o:"supportteam-sc-demos" ` + /d:sonar.login="${{ secrets.SONAR_TOKEN }}" ` /d:sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 # <-- Add this step + - name: Build Solution with Build Wrapper run: | - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} dotnet build CPlusPlusAndCSharp.sln --no-incremental + build-wrapper-win-x86-64 --out-dir $env:BUILD_WRAPPER_OUT_DIR msbuild CPlusPlusAndCSharp.sln /p:Configuration=Release + shell: pwsh # Use PowerShell for Windows - name: SonarScanner for .NET - End env: From 1ff5f0f4dce1c03e29e128a695ec003b2f4afd9b Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:58:05 -0500 Subject: [PATCH 10/13] Update build.yml - Correct NuGet error --- .github/workflows/build.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b86f05e..77927a2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,13 +5,15 @@ on: - main pull_request: types: [opened, synchronize, reopened] + jobs: build: name: Build and analyze - runs-on: windows-latest # <-- Changed from ubuntu-latest to windows-latest + runs-on: windows-latest env: BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory SONAR_SCANNER_PROJECT_KEY: SupportTeam-SC-demos_kilo-cppAndcSharp + steps: - uses: actions/checkout@v4 with: @@ -39,12 +41,15 @@ jobs: /d:sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" - name: Setup MSBuild - uses: microsoft/setup-msbuild@v2 # <-- Add this step + uses: microsoft/setup-msbuild@v2 + + - name: Restore .NET dependencies + run: dotnet restore CPlusPlusAndCSharp.sln - name: Build Solution with Build Wrapper run: | build-wrapper-win-x86-64 --out-dir $env:BUILD_WRAPPER_OUT_DIR msbuild CPlusPlusAndCSharp.sln /p:Configuration=Release - shell: pwsh # Use PowerShell for Windows + shell: pwsh - name: SonarScanner for .NET - End env: From ba02a4b768384382e5902a6d8f33f30504a82a8f Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:12:20 -0500 Subject: [PATCH 11/13] Delete sonar-project.properties Supposedly this was causing an error with the .NET end statement --- sonar-project.properties | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 5642ed5..0000000 --- a/sonar-project.properties +++ /dev/null @@ -1,14 +0,0 @@ -sonar.projectKey=SupportTeam-SC-demos_kilo-cppAndcSharp -sonar.organization=supportteam-sc-demos - - -# This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=kilo-cppAndcSharp -#sonar.projectVersion=1.0 - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 From 92833318116f6d03dbcb55566d76def1059ceaaf Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:23:32 -0500 Subject: [PATCH 12/13] Delete CPlusPlusAndCSharp/sonar-project.properties --- CPlusPlusAndCSharp/sonar-project.properties | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CPlusPlusAndCSharp/sonar-project.properties diff --git a/CPlusPlusAndCSharp/sonar-project.properties b/CPlusPlusAndCSharp/sonar-project.properties deleted file mode 100644 index b24cc20..0000000 --- a/CPlusPlusAndCSharp/sonar-project.properties +++ /dev/null @@ -1 +0,0 @@ -sonar.projectKey=kiloecho-sonar_cppAndcSharp_31bc1e05-0358-4305-993a-c4367ca5a954 From 7ea8ec583042d3027379da83daa5c4ccce8d52ba Mon Sep 17 00:00:00 2001 From: Keith E <129207802+kiloecho-sonar@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:24:24 -0500 Subject: [PATCH 13/13] Delete CSharpProject/sonar-project.properties --- CSharpProject/sonar-project.properties | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CSharpProject/sonar-project.properties diff --git a/CSharpProject/sonar-project.properties b/CSharpProject/sonar-project.properties deleted file mode 100644 index b24cc20..0000000 --- a/CSharpProject/sonar-project.properties +++ /dev/null @@ -1 +0,0 @@ -sonar.projectKey=kiloecho-sonar_cppAndcSharp_31bc1e05-0358-4305-993a-c4367ca5a954