This solution is for Subversion and Maven.
- Install the Parameterized Trigger Plugin
- Create a Maven job for the SonarQube analysis, eg.
_common-sonar with these settings:
- Source Code Management: "Subversion", Repository URL:
$PREVIOUS_SVN_URL, Check-out Strategy: "Always check out a fresh copy"
- Build: Goals and options:
install
- Post-build Actions: "Sonar"
- For the job you want to run analysis on add a Post-build Action "Trigger parameterized build on other projects" with these settings:
- Projects to build:
_common-sonar
- Add Predefined parameters: Parameters:
PREVIOUS_SVN_URL=${SVN_URL}
Now when the job-to-analyse completes it triggers the analysis job. The analysis job checks out the same SVN URL which was used by the first job.
This solution works without scripting or copying workspaces but there are quite obvious limitations and non-ideal features:
- the build command is always only
mvn install
- the SVN checkout may be from different revision than original build
- checkout and build are always done from scratch
- I didn't consider ant at all here.
Improvement ideas are quite welcome!
Late improvement edit:
Instead of using a maven build ( in _common-sonar), you may also use SonarQube directly by invoking a Standalone SonarQube analysis
Additionally to the SVN URL you can add a parameter for the build tag and project name to use in sonar. Simply add
- NAME=YOUR_PROJECT_NAME
- BUILDTAG=$BUILD_TAG
beneath the PREVIOUS_SVN_URL parameter.
In your _common-sonar you can use it with ${NAME} and ${BUILDTAG}.