I have a multi-module maven project that I'm trying to analyze with SonarQube via Bitbucket Pipelines. I've gotten both modules reporting on SonarQube properly, but my pipeline triggers each step regardless of the changesets condition being true or not. My repo is setup like this:
Root-module1
-src files
-test files
-module2
-src files
-test files
I want only the files under module1 to be analyzed when any file within the module1 folder is modified. Module2 should not analyze unless a file under module2 is modified.
Here is my bitbucket-pipelines.yml:
image: maven:3-eclipse-temurin-17
definitions:
steps:
- step: &mod1-step
name: SonarQube analysis
caches:
- maven
- sonar
script:
-mvn verify sonar:sonar
-Dsonar.projectKey=ks_mavenmono_mod1
-Dsonar.projectName='Maven-Mono-Mod1'
-Dsonar.inclusions=module1/**
- step: &mod2-step
name: SonarQube analysis
caches:
- maven
- sonar
script:
-mvn verify sonar:sonar
-Dsonar.projectKey=ks_mavenmono_mod2
-Dsonar.projectName='Maven-Mono-Mod2'
-Dsonar.inclusions=module2/**
caches:
sonar: ~/.sonar
clone:
depth: full
pipelines:
default:
- step:
runs-on:
- self.hosted
- macos
branches:
'{main, devBranch}':
- step: *mod1-step
condition:
changesets:
includePaths:
- "module1/**"
- step: *mod2-step
condition:
changesets:
includePaths:
- "module2/**"
pull-requests:
'**':
- step: *mod1-step
condition:
changesets:
includePaths:
- "module1/**"
- step: *mod2-step
condition:
changesets:
includePaths:
- "module2/**"
G'day, @Keith Everitt
Welcome to the community!
I believe there's a slight issue with your YML config, please use the following example and see if that works:
image: maven:3-eclipse-temurin-17 definitions: steps: - step: &mod1-step name: SonarQube analysis script: - echo "test" - step: &mod2-step name: SonarQube analysis script: - echo "test" clone: depth: full pipelines: branches: '{main, devBranch}': - step: <<: *mod1-step condition: changesets: includePaths: - "module1/**" - step: <<: *mod2-step condition: changesets: includePaths: - "module2/**"
Make sure the spaces are as above example or otherwise, it will fail to work.
Regards,
Syahrul
Syahrul,
Thanks for the quick reply, this worked perfectly. Much appreciated
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.