Set up your SCM system

If your CI server is set up to work with a source control management (SCM) system, such as Git or Subversion (SVN), you can use the integration to track committed changes. For details, see Track commits to your SCM system.

This topic explains how to customize SCM-related functionality.

Enable links to the Git or SVN viewer

For each file displayed in the list of changed files, you can enable links to the file view and diff view in your repository viewer. To enable the links, configure templates for the HTTP links.

This functionality is provided for repository viewers whose HTTP link templates include the file path and the revision.

To configure templates for links to your repository viewer:

  1. Open the Settings menu , click Spaces, and select the workspace that is set up to integrate with your CI server.

  2. In the DevOps tab, select SCM Repositories.

    This page lists any source code repositories that integrate with your CI servers.

    Note: A repository is only displayed in this list after a pipeline run includes commits to the repository.

  3. For each repository, enter the relevant link templates.

    Template field Description
    File in revision link A template for the HTTP link to file views.
    Diff link

    A template for the HTTP link to the diff view of a selected file version.

    Branch/file link

    A template for the HTTP link to branches and files in a branch.

    Pull request link A template for the HTTP link to pull requests.

    In each of the template fields, type a pattern that consists of the actual repository URL and placeholders for the SCM entity, such as {filePath} and {revision}. See examples below.

Back to top

Examples of link templates

The following are examples of templates for the available repository viewers.

Bitbucket

Template Description
File in revision link

<REPOSITORY_URL>/browse/{filePath}?until={revision}&untilPath={filePath}

Diff link

<REPOSITORY_URL>/commits/{revision}#{filePath}

Branch/file link

<REPOSITORY_URL>/browse/{filePath}?at={branchName}

GitLab and GitHub

Template Description
File in revision link

<REPOSITORY_URL>/blob/{revision}/{filePath}

Diff link

<REPOSITORY_URL>/commit/{revision}#{filePath}

Branch/file link

<REPOSITORY_URL>/tree/{branchName}/{filePath}

Pull request link <REPOSITORY_URL>/{pullRequestID}

Azure

Template Description
File in revision link

<REPOSITORY_URL>?path={filePath}&_a=contents&{revision}

Diff link

<REPOSITORY_URL>/commit/{revision}?refName={branchName}&path={filePath}

Branch/file link

{repoUrl}?version=GB{branchName}/{​​​​​​filePath}

Back to top

Customize SCM change patterns

You can use message patterns in your branches, commits, and pull requests to associate them with backlog items or other entities.

If the specified entity pattern appears in a branch name, commit message, or in the title or description of a pull request, the branch, commit, or pull request will be associated with the corresponding entity.

To modify default message patterns or define new patterns using Java regular expressions:

  1. Open the Settings menu , click Spaces, and select the workspace that is set up to integrate with your CI server.

  2. In the DevOps tab, select SCM Change Patterns.

  3. Define the message patterns to use for associating branches, commits, and pull requests with entities.

    • Commits can be associated with backlog items: user stories, quality stories, and defects.

    • Branches and pull requests can be associated with backlog items and with features.

    Change an existing pattern, or click the Pattern button to add a new pattern. Using Java regular expressions, design a pattern that contains a single capturing group containing the story ID.

    For example, the default pattern defect\s*#(\d+) represents the string defect<any number of spaces>#<defect id>.

    The patterns are not case sensitive.

  4. Click the Validate pattern button to experiment with your patterns and make sure that they match the string that you had in mind.

    For example, in the Validate Pattern dialog box, enter an experimental commit message. Click Validate to see the stories that your commit patterns associate with this comment.

    Repeat this step to test all of the patterns you defined.

  5. Make sure to tell your SCM users about the patterns their branch names, commit messages, and pull requests must follow, so that they are associated with their corresponding entities.

Back to top

See also: