Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Maven mono repo will not analyze based on changesets

Keith Everitt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 29, 2024

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/**"

 

1 answer

1 accepted

2 votes
Answer accepted
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 1, 2024

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

Keith Everitt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 2, 2024

Syahrul,

Thanks for the quick reply, this worked perfectly.  Much appreciated

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events