11
11
USERPROFILE : C:\sonar-ci
12
12
PATH : C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool;C:\Program Files\DigiCert\DigiCert One Signing Manager Tools;C:\sonar-ci\.dotnet\tools;${PATH}
13
13
CIRRUS_WORKING_DIR : C:\sonar-ci
14
- CIRRUS_CLONE_DEPTH : 50
15
14
16
15
ec2_instance_definition : &INSTANCE_DEFINITION
17
16
region : eu-central-1
18
- type : t3a .xlarge
17
+ type : c6i .xlarge
19
18
image : base-windows-dotnet-v20240523071308
20
19
platform : windows
21
20
@@ -41,6 +40,8 @@ build_task:
41
40
SONARSOURCE_SNK_FILE : ${TMP_DIR}\SonarSource.snk
42
41
SONARSOURCE_SNK : VAULT[development/team/languages/kv/data/strong_named_key data.SonarSourceSecret_snk]
43
42
SONAR_TOKEN : VAULT[development/kv/data/sonarcloud data.token]
43
+ SIGN_KEY : VAULT[development/kv/data/sign data.key]
44
+ SIGN_PASSPHRASE : VAULT[development/kv/data/sign data.passphrase]
44
45
clone_script : |
45
46
git config --global core.autocrlf true
46
47
git init
@@ -50,7 +51,7 @@ build_task:
50
51
51
52
calculate_version_script : *CALCULATE_VERSION_SCRIPT_DEFINITION
52
53
prepare_signing_script : |
53
- if [[ "${CIRRUS_BRANCH}" == "${CIRRUS_DEFAULT_BRANCH}" || "${CIRRUS_BRANCH}" =~ " branch-.*" || "${CIRRUS_BRANCH}" =~ " sign-.*" ]] ; then
54
+ if [[ "${CIRRUS_BRANCH}" == "${CIRRUS_DEFAULT_BRANCH}" ]] || echo "${CIRRUS_BRANCH}" | grep -qE "^ branch-.*" || echo "${CIRRUS_BRANCH}" | grep -qE "^ sign-.*"; then
54
55
mkdir -p "${TMP_DIR}"
55
56
echo "${SONARSOURCE_SNK}" | base64 -d > "${SONARSOURCE_SNK_FILE}"
56
57
echo "${SM_CLIENT_CERT_FILE_BASE64}" | base64 -d > "${SM_CLIENT_CERT_FILE}"
@@ -74,14 +75,27 @@ build_task:
74
75
msbuild.exe "${SOLUTION_PATH}" -p:VsVersion=17.0 -p:VsTargetVersion=2022 -p:SignArtifacts=${SHOULD_SIGN} -p:AssemblyOriginatorKeyFile=${SONARSOURCE_SNK_FILE} -p:DeployExtension=false -p:Sha1=${CIRRUS_CHANGE_IN_REPO} -p:BuildNumber=${CI_BUILD_NUMBER} -p:Configuration=Release
75
76
sign_artifact_script : |
76
77
if [[ "${SHOULD_SIGN}" == "true" ]]; then
77
- nuget sign "binaries/SonarLint.VSIX-${SONAR_PROJECT_VERSION}.${CIRRUS_BUILD_ID }-2022.vsix" -HashAlgorithm SHA256 -CertificateFingerprint ${SM_CERT_FP} -Timestamper http://timestamp.digicert.com -TimestampHashAlgorithm SHA256
78
+ nuget sign "binaries/SonarLint.VSIX-${SONAR_PROJECT_VERSION}.${CI_BUILD_NUMBER }-2022.vsix" -HashAlgorithm SHA256 -CertificateFingerprint ${SM_CERT_FP} -Timestamper http://timestamp.digicert.com -TimestampHashAlgorithm SHA256
78
79
else
79
80
echo "Artifact not signed"
80
81
fi
81
82
tests_script : |
82
83
vstest.console.exe --EnableCodeCoverage --Logger:trx --ResultsDirectory:"TestResults" src/**/bin/**/Sonar*.*Tests.dll
83
84
sonarcloud_analysis_script :
84
85
- dotnet sonarscanner end -d:sonar.token=${SONAR_TOKEN}
86
+ sbom_generation_script : |
87
+ if [[ "${SHOULD_SIGN}" == "true" ]]; then
88
+ sbomname="SonarLint.visualstudio.sbom-$SONAR_PROJECT_VERSION.$CI_BUILD_NUMBER-2022.json"
89
+ gpg --batch --passphrase "$SIGN_PASSPHRASE" --allow-secret-key-import --import <(echo "$SIGN_KEY")
90
+ gpg --list-secret-keys
91
+ dotnet tool install --global CycloneDX
92
+ dotnet CycloneDX SonarLint.VisualStudio.Integration.sln -t -j -o binaries
93
+ cd binaries
94
+ mv bom.json $sbomname
95
+ gpg --pinentry-mode loopback --passphrase "$SIGN_PASSPHRASE" --armor --detach-sig --default-key infra@sonarsource.com "$sbomname"
96
+ echo "signed $sbomname"
97
+ ls -al
98
+ fi
85
99
86
100
dogfood_task :
87
101
depends_on :
0 commit comments