Add SCM (source code management) data into ALM Octane

Use this topic to learn how you can inject SCM Data into ALM Octane using the REST API. Then you can use ALM Octane to track commits and other relevant data such as repositories and branches, and perform code analysis.

Flow

To manually inject SCM data to the ALM Octane server: 

  1. Authenticate and sign in as a user with the necessary permissions.

  2. Create a JSON payload for the vulnerabilities.

  3. Push the SCM data using the custom resource SCM data into ALM Octane.

  4. Check the status of the push.

Back to top

Create the SCM data payload

You can see existing scm_commits and their IDs using a GET operation:

GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/scm_commits

You can see existing SCM branches and their IDs using a GET operation:

GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/scm_repositories

Follow the same JSON format to prepare your payload. You will use the payload to:

  • Identify the pipeline run entities for which you want to create or update SCM data.

  • Send ALM Octane the commits to associate with the pipeline runs.

Back to top

Push the SCM data into ALM Octane

Use the PUT operation with a payload to create new SCM Data entities, like repositories, branches, and commits.

PUT .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/scm-commits

For details, see the special resource: SCM data.

Back to top

Check results

If successful, return code 200 is returned.

Make sure the SCM data has been pushed correctly into ALM Octane.

  1. Check the response for errors that may have occurred.

  2. Check if the commits exist in ALM Octane. For details, see Track changes committed to your Source Control Management system.

Back to top

Examples

For example, we have in the request:

Example: GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/scm_commits/1213269?fields=creation_time,client_lock_stamp,stories,version_stamp,commit_time,revision,workspace_id,repositories,name,workspace_user,risk,comment,last_modified,user,email

Without workspace user, repositories, and stories, the response will be:

Example: GET .../api/shared_spaces/<space_id>/workspaces/<workspace_id>/scm_commits/1213269?fields=creation_time,client_lock_stamp ,version_stamp,commit_time,revision,workspace_id,name,risk,comment,last_modified,user,email

{
    "type": "scm_commit",
    "last_modified": "2020-08-22T22:31:25Z",
    "revision": "53e564566a75fcc073a5ed0dd71bad0f0f588855",
    "creation_time": "2020-08-20T08:34:10Z",
    "user": "userName",
    "risk": false,
    "comment": "user story #1053020. user story 11111111",
    "commit_time": "2020-08-20T08:33:06Z",
    "name": "commit name",
    "workspace_id": 33006,
    "id": "1213269",
    "version_stamp": 14,
    "client_lock_stamp": 1
}

With the SCM data, the response will be:

Example: {
    "type": "scm_commit",
    "last_modified": "2020-08-22T22:31:25Z",
    "revision": "53e564566a75fcc073a5ed0dd71bad0f0f588855",
    "creation_time": "2020-08-20T08:34:10Z",
    "user": "evgene.lock",
    "risk": false,
    "comment": "user story #1053020. user story 11111111",
    "commit_time": "2020-08-20T08:33:06Z",
    "name": "commit name",
    "workspace_id": 33006,
    "id": "1213269",
    "version_stamp": 14,
    "client_lock_stamp": 1,
    "stories": {
            "total_count": 1,
            "data": [{
                           "type": "work_item",
                           "id": "1053020",
                           "name": "US1",
                           "subtype": "story"
                   }
            ]
    },
    "repositories": {
            "total_count": 1,
            "data": [{
                           "type": "scm_repository",
                           "scm_source_view": null,
                           "scm_type": 2,
                           "scm_diff": null,
                           "workspace_id": 33006,
                           "branch": "refs/heads/master",
                           "id": "324004",
                           "name": "repository.git:master",
                           "url": "https://github.com/repository.git"
                   }
            ]
    },
    "workspace_user": {
            "type": "workspace_user",
            "id": "117001",
            "workspace_id": 33006,
            "activity_level": 0,
            "full_name": "User Name",
            "name": "userName@mail.com"
    }
}

Back to top

See also: