Best Practice: Project with a Java backend and a Typescript frontend?

Must-share information (formatted with Markdown):

  • SonarQube 7.9.1, Jenkins 2.207
  • Code analysis and Code coverage on a project with both Java and TypeScript
  • Created the below pipeline:
 stages {
    stage('NPM Build') {
        steps {
            script {
                        sh 'npm --no-color install && npm --no-color run ci && npm --no-color run build:prod'
                    }
                }
            }
    stage('Maven Build') {
        steps {
            script {
                withSonarQubeEnv('MySonarQube') {
                            sh "mvn -e clean package sonar:sonar"
            }
        }
        post {
            success {
                // Calculate Jacoco Code Coverage
                junit '**/target/surefire-reports/*.xml'
                jacoco()
            }
        }
    }
}

My question:
How do I modify this to get the TypeScript code analysis and code coverage? Is it best practice to:
a) Create a separate stage that will analyze frontend and backend at the same time? If so, should I use sonar-scanner with tool defined?
b) Add a separate withSonarQubeEnv(‘MySonarQube’) to the NPM build stage?
c) Add the sonar maven plugin to my root pom and pass a -Dsonar.sources with the frontend and backend directories

I would really appreciate some guidance here.

Thank You!

Hi,

You’re going to do your Java build and get both coverage reports, and only then run analysis. SonarQube will automatically pick up both languages, but you will need to make sure you tell it where your coverage reports are.

 
HTH,
Ann

1 Like