Parasoft DTP can display sources directly from your source control management system (SCM) in Explorer Views. To enable this functionality, DTP must be configured to read sources from the SCM. In addition, the Parasoft tools must be connected to the SCM during analysis so that the reports sent to DTP contain information about the SCM.
Configuring Source Control Settings
You can configure source control settings for your project in the Parasoft Tool Settings section of Project settings.
In the rare case that you want to configure source control settings that apply across all your projects, you can do so in the global tool settings.
Displaying Sources from Git Repositories
You will need to configure DTP as outlined below in order to display your tested project's source code from a Git repository.
Create a local clone of the Git repository on the machine where DTP is installed. If it's not already installed, download and install the Git client, then choose a location for the clone and run:
git clone --mirror <URL_TO_REMOTE_REPO>
Do this for each Git repository that you test with Parasoft tools and want to see the tested source code in DTP.
In order for DTP to show the proper code, you need to ensure that your clones stay up to date. To update a clone, run:
git remote update <URL_TO_REMOTE_REPO>
It is recommended that you automate this task, for example with a Jenkins job or a Linux cron job. Do this for each repository you cloned in the step above.
Within DTP, go to the Report Center Settings and configure the tool settings for your DTP project so that it points to your local Git clones. See Configuring Parasoft Tool Settings for Projects for more information about this process. The example below shows a configuration for two Git repositories,
scontrol.rep1.git.workspaceandscontrol.rep2.git.workspace, but you should configure for as many repositories as you cloned.scontrol.rep1.git.workspace=<LOCAL_CLONE_DIRECTORY> scontrol.rep1.git.branch=master scontrol.rep1.type=git scontrol.rep1.git.url=<URL_TO_REMOTE_REPO> scontrol.rep2.git.workspace=<LOCAL_CLONE_DIRECTORY> scontrol.rep2.git.branch=master scontrol.rep2.type=git scontrol.rep2.git.url=<URL_TO_REMOTE_REPO>
Displaying Sources from SVN Repositories
The following configuration is an example of an SVN connection.
scontrol.rep.type=svn scontrol.rep.svn.url=https://svn_server/ scontrol.rep.svn.login=username scontrol.rep.svn.password=password scontrol.svn.exec=/usr/bin/svn
DTP can track canonical files that appear in different SVN branches if the scontrol.rep.svn.url setting is configured properly. This settings specifies the SVN repository URL.
Configure the scontrol.rep.svn.url setting to the node containing the project, but do not include the project name.
For example, if a file in SVN is part of a project named “mina” with the following absolute path:
https://svn.apache.org/repos/asf/mina/trunk/examples/src/http/BogusSslContextFactory.java
The CLI settings should be set to:
scontrol.rep.svn.url=https\://svn.apache.org/repos/asf
Do not include a trailing slash (/). Make sure to keep this consistent across all projects.
Configuring Hyperlinks to the Source Control System
You can configure DTP to add a hyperlink in the source code viewer that opens the file directly in your source control system’s web interface. See the following example configuration for a Git repository hosted on Atlassian Bitbucket:
server.scontrol.rep1.web.name=Bitbucket
server.scontrol.rep1.web.url=https://git.parasoft.com/projects/myProject/repos/project/browse/{scontrol_path}?at={scontrol_revision}#{start_line}
Note: This assumes you have configured DTP as explained in Displaying Sources from Git Repositories above.
Suppose you are viewing source code of a violation for Foo.java with the following properties:
- source control path:
com.parasoft.foo/src/main/java/com/parasoft/foo/Foo.java - git revision:
9b590edd6413b68fe6648aa5c525f88819c62bba - line number:
80
With the above settings configured, the DTP source code viewer will show a "View in Bitbucket" hyperlink at the top:
And the hyperlink will resolve to:
https://git.parasoft.com/projects/myProject/repos/project/browse/com.parasoft.foo/src/main/java/com/parasoft/foo/Foo.java?at=9b590edd6413b68fe6648aa5c525f88819c62bba#80
How Variable Substitution Works
The value of server.scontrol.rep1.web.name appears in the hyperlink text after “View in”.
Additionally, DTP dynamically injects the following values into the configured URL:
{scontrol_path}is replaced with the file’s source control path{scontrol_revision}is replaced with the Git revision{start_line}is replaced with the line number{scontrol_branch}is replaced with the Git branch name
Supported Source Control Systems
The following source control systems are supported:
- Atlassian Bitbucket
- GitHub
- GitLab
Each system uses a slightly different URL format, so be sure to adjust the value of server.scontrol.rep1.web.url according to your provider’s URL conventions.
Troubleshooting Issues with Source Control System
When source code cannot be displayed from Source Control System:
- Ensure that the report.xml file is published to DTP has source control information. Check that
<Repositories..>section is present. If this is not the case, then the Parasoft tool configuration is incorrect - Check the source code panel in an explorer view for important information.
- Ensure that all repository settings are present in Parasoft Tool setting. Credentials and other repository settings are necessary to display source code
- Ensure that the source control client is available to DTP and correctly configured. Ensure that the client can access the source code using credentials that are configured for DTP.
- For some source control systems, such as Git, ensure that the repository is cloned and up-to-date at DTP. An external cron job may be necessary for Git to update the local repository regularly.
- Verify that your SCM supports modifying, moving, or copying sources during build in order to rule-out disconnecting from the original source control system.
