aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2022-01-05 10:22:49 +0100
committersonartech <sonartech@sonarsource.com>2022-01-06 20:03:09 +0000
commitc3ab9ef193d6e006fc821cf771850656146c0199 (patch)
tree4bafc971381caaacca67a87e32e5181724c902ef /server/sonar-web/src/main/js
parent1270fd65a95fc50b8f59bbc15bb94e183fb09b12 (diff)
downloadsonarqube-c3ab9ef193d6e006fc821cf771850656146c0199.tar.gz
sonarqube-c3ab9ef193d6e006fc821cf771850656146c0199.zip
[NO JIRA] Use YAML anchors to make Bitbucket Pipelines examples DRYer
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap346
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts48
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts62
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts34
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts34
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts33
6 files changed, 257 insertions, 300 deletions
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
index 7384d2d1b4e..697363c2ecc 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
@@ -31,28 +31,31 @@ exports[`should render correctly for cfamily 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: <image ready for your build toolchain>
+definitions:
+ steps:
+ - step: &build-step
+ name: Download and install the build wrapper, build the project
+ script:
+ - mkdir $HOME/.sonar
+ - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
+ - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
+ - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
+ SONAR_HOST_URL: \${SONAR_HOST_URL}
+ SONAR_TOKEN: \${SONAR_TOKEN}
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: Download and install the build wrapper, build the project
- script:
- - mkdir $HOME/.sonar
- - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
- SONAR_HOST_URL: \${SONAR_HOST_URL}
- SONAR_TOKEN: \${SONAR_TOKEN}
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step
+"
/>
<CompilationInfo
className="abs-width-800"
@@ -91,42 +94,34 @@ exports[`should render correctly for cfamily: with branch enabled 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: <image ready for your build toolchain>
+definitions:
+ steps:
+ - step: &build-step
+ name: Download and install the build wrapper, build the project
+ script:
+ - mkdir $HOME/.sonar
+ - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
+ - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
+ - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
+ SONAR_HOST_URL: \${SONAR_HOST_URL}
+ SONAR_TOKEN: \${SONAR_TOKEN}
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: Download and install the build wrapper, build the project
- script:
- - mkdir $HOME/.sonar
- - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
- SONAR_HOST_URL: \${SONAR_HOST_URL}
- SONAR_TOKEN: \${SONAR_TOKEN}
+ - step: *build-step
pull-requests:
'**':
- - step:
- name: Download and install the build wrapper, build the project
- script:
- - mkdir $HOME/.sonar
- - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
- SONAR_HOST_URL: \${SONAR_HOST_URL}
- SONAR_TOKEN: \${SONAR_TOKEN}
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step"
/>
<CompilationInfo
className="abs-width-800"
@@ -164,27 +159,30 @@ exports[`should render correctly for dotnet 1`] = `
<CreateYmlFile
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: mcr.microsoft.com/dotnet/core/sdk:latest
-
+
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - dotnetcore
+ - sonar
+ script:
+ - apt-get update
+ - apt-get install --yes openjdk-11-jre
+ - dotnet tool install --global dotnet-sonarscanner
+ - export PATH=\\"$PATH:/root/.dotnet/tools\\"
+ - dotnet sonarscanner begin /k:\\"my-project\\" /d:\\"sonar.login=\${SONAR_TOKEN}\\" /d:\\"sonar.host.url=\${SONAR_HOST_URL}\\"
+ - dotnet build
+ - dotnet sonarscanner end /d:\\"sonar.login=\${SONAR_TOKEN}\\"
+ caches:
+ sonar: ~/.sonar
+
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH=\\"$PATH:/root/.dotnet/tools\\"
- - dotnet sonarscanner begin /k:\\"my-project\\" /d:\\"sonar.login=\${SONAR_TOKEN}\\" /d:\\"sonar.host.url=\${SONAR_HOST_URL}\\"
- - dotnet build
- - dotnet sonarscanner end /d:\\"sonar.login=\${SONAR_TOKEN}\\"
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step
+"
/>
</Fragment>
`;
@@ -219,43 +217,33 @@ exports[`should render correctly for dotnet: with branch enabled 1`] = `
<CreateYmlFile
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: mcr.microsoft.com/dotnet/core/sdk:latest
-
+
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - dotnetcore
+ - sonar
+ script:
+ - apt-get update
+ - apt-get install --yes openjdk-11-jre
+ - dotnet tool install --global dotnet-sonarscanner
+ - export PATH=\\"$PATH:/root/.dotnet/tools\\"
+ - dotnet sonarscanner begin /k:\\"my-project\\" /d:\\"sonar.login=\${SONAR_TOKEN}\\" /d:\\"sonar.host.url=\${SONAR_HOST_URL}\\"
+ - dotnet build
+ - dotnet sonarscanner end /d:\\"sonar.login=\${SONAR_TOKEN}\\"
+ caches:
+ sonar: ~/.sonar
+
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH=\\"$PATH:/root/.dotnet/tools\\"
- - dotnet sonarscanner begin /k:\\"my-project\\" /d:\\"sonar.login=\${SONAR_TOKEN}\\" /d:\\"sonar.host.url=\${SONAR_HOST_URL}\\"
- - dotnet build
- - dotnet sonarscanner end /d:\\"sonar.login=\${SONAR_TOKEN}\\"
-
+ - step: *build-step
+
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH=\\"$PATH:/root/.dotnet/tools\\"
- - dotnet sonarscanner begin /k:\\"my-project\\" /d:\\"sonar.login=\${SONAR_TOKEN}\\" /d:\\"sonar.host.url=\${SONAR_HOST_URL}\\"
- - dotnet build
- - dotnet sonarscanner end /d:\\"sonar.login=\${SONAR_TOKEN}\\"
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step"
/>
</Fragment>
`;
@@ -291,23 +279,26 @@ exports[`should render correctly for gradle 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: openjdk:8
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - gradle
+ - sonar
+ script:
+ - bash ./gradlew sonarqube
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step
+"
/>
</Fragment>
`;
@@ -343,33 +334,29 @@ exports[`should render correctly for gradle: with branch enabled 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: openjdk:8
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - gradle
+ - sonar
+ script:
+ - bash ./gradlew sonarqube
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
+ - step: *build-step
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step"
/>
</Fragment>
`;
@@ -405,23 +392,26 @@ exports[`should render correctly for maven 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: maven:3-openjdk-11
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - maven
+ - sonar
+ script:
+ - mvn verify sonar:sonar -Dsonar.projectKey=my-project
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar -Dsonar.projectKey=my-project
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step
+"
/>
</Fragment>
`;
@@ -457,33 +447,29 @@ exports[`should render correctly for maven: with branch enabled 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: maven:3-openjdk-11
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - maven
+ - sonar
+ script:
+ - mvn verify sonar:sonar -Dsonar.projectKey=my-project
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar -Dsonar.projectKey=my-project
+ - step: *build-step
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar -Dsonar.projectKey=my-project
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step"
/>
</Fragment>
`;
@@ -519,23 +505,26 @@ exports[`should render correctly for other 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: maven:3.3.9
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ script:
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
+ SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step
+"
/>
</Fragment>
`;
@@ -571,33 +560,30 @@ exports[`should render correctly for other: with branch enabled 1`] = `
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: maven:3.3.9
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ script:
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
+ SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+ - step: *build-step
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
-
-definitions:
- caches:
- sonar: ~/.sonar"
+ - step: *build-step
+"
/>
</Fragment>
`;
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts
index bea52d0f861..3aa24a50cb3 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts
@@ -21,44 +21,36 @@
export default function cFamilyExample(branchesEnabled: boolean) {
return `image: <image ready for your build toolchain>
+definitions:
+ steps:
+ - step: &build-step
+ name: Download and install the build wrapper, build the project
+ script:
+ - mkdir $HOME/.sonar
+ - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
+ - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
+ - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
+ SONAR_HOST_URL: \${SONAR_HOST_URL}
+ SONAR_TOKEN: \${SONAR_TOKEN}
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: Download and install the build wrapper, build the project
- script:
- - mkdir $HOME/.sonar
- - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
- SONAR_HOST_URL: \${SONAR_HOST_URL}
- SONAR_TOKEN: \${SONAR_TOKEN}
+ - step: *build-step
${
branchesEnabled
? `
pull-requests:
'**':
- - step:
- name: Download and install the build wrapper, build the project
- script:
- - mkdir $HOME/.sonar
- - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
- SONAR_HOST_URL: \${SONAR_HOST_URL}
- SONAR_TOKEN: \${SONAR_TOKEN}`
+ - step: *build-step`
: ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`;
+}`;
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts
index 1cda1d0a7fd..a2e7f9d5b9d 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts
@@ -20,45 +20,35 @@
export default function dotNetExample(branchesEnabled: boolean, projectKey: string) {
return `image: mcr.microsoft.com/dotnet/core/sdk:latest
-
+
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - dotnetcore
+ - sonar
+ script:
+ - apt-get update
+ - apt-get install --yes openjdk-11-jre
+ - dotnet tool install --global dotnet-sonarscanner
+ - export PATH="$PATH:/root/.dotnet/tools"
+ - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
+ - dotnet build
+ - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
+ caches:
+ sonar: ~/.sonar
+
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH="$PATH:/root/.dotnet/tools"
- - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
- - dotnet build
- - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
- ${
- branchesEnabled
- ? `
+ - step: *build-step
+${
+ branchesEnabled
+ ? `
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH="$PATH:/root/.dotnet/tools"
- - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
- - dotnet build
- - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
- `
- : ''
- }
-definitions:
- caches:
- sonar: ~/.sonar`;
+ - step: *build-step`
+ : ''
+}`;
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts
index 35afb573797..8360c1d6c6f 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts
@@ -21,35 +21,31 @@
export default function gradleExample(branchesEnabled: boolean) {
return `image: openjdk:8
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - gradle
+ - sonar
+ script:
+ - bash ./gradlew sonarqube
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
+ - step: *build-step
${
branchesEnabled
? `
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
-`
+ - step: *build-step`
: ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`;
+}`;
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts
index 9e63d9c4c62..f45ad31efa7 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts
@@ -21,35 +21,31 @@
export default function mavenExample(branchesEnabled: boolean, projectKey: string) {
return `image: maven:3-openjdk-11
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ caches:
+ - maven
+ - sonar
+ script:
+ - mvn verify sonar:sonar -Dsonar.projectKey=${projectKey}
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar -Dsonar.projectKey=${projectKey}
+ - step: *build-step
${
branchesEnabled
? `
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar -Dsonar.projectKey=${projectKey}
-`
+ - step: *build-step`
: ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`;
+}`;
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts
index d06403f8b8c..3a918d36883 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts
@@ -21,35 +21,32 @@
export default function othersExample(branchesEnabled: boolean) {
return `image: maven:3.3.9
+definitions:
+ steps:
+ - step: &build-step
+ name: SonarQube analysis
+ script:
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
+ SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+ caches:
+ sonar: ~/.sonar
+
clone:
depth: full
pipelines:
branches:
'{master}': # or the name of your main branch
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+ - step: *build-step
${
branchesEnabled
? `
pull-requests:
'**':
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+ - step: *build-step
`
: ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`;
+}`;
}