Automatically derive mandatory SonarQube properties from pom file in Jenkins

前端 未结 2 1383
故里飘歌
故里飘歌 2021-01-02 03:39

Situation:

I want to analyze my project with SonarQube (5.4) triggered by Jenkins (1.642.4). It is a java project build with maven.

I see tw

2条回答
  •  -上瘾入骨i
    2021-01-02 04:36

    The documentation (although slightly confusing, see edit below) explains how to use a generic post-build step (leveraging environment variables), instead of the deprecated post-build action. in short:

    • install latest SonarQube Plugin (v2.4 as of now) in Jenkins
    • in System Config under SonarQube servers: check Enable injection of SonarQube server configuration as build environment variables
    • in the configuration of your Maven project:
      • check Prepare SonarQube Scanner environment
      • add a post-build step Invoke top-level Maven targets and leverage the injected environment variables in the Goals field e.g.:

        $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN

    Edit: when the documentation says The Post-build Action for Maven analysis is deprecated. , it refers to the old post-build action which is not documented anymore. The paragraph after that warning (summarized in this answer) really is the recommended procedure. Illustration here if it's still not clear.

提交回复
热议问题