Main Content

Add Labels to Project Runs in Polyspace Access

To help identify project runs uploaded to Polyspace® Access, you can assign custom labels to runs. Custom labels are in addition to the unique run IDs that Polyspace Access assigns to each run.

You can assign labels from the user interface through the Project Details pane on the Dashboard, or from the command line.

Manage Labels in the User Interface

To add a label to a run, first select a project in the Project Explorer. Select the run that you want to add a label to by using the Current drop-down list.

current run dropdown menu

In the Project Details pane, in the Labels box under the Run section, click the add label icon icon. In the Add label to current run box, enter the label name to assign to the run, and then click OK.

Add label to run dialog box

Labels are sorted in alphabetical order. There is no limit on how many labels you can assign to a single run.

To delete a label, select the label and click the remove label icon icon. You can select multiple labels to delete them simultaneously.

Run label list

Manage Labels at the Command Line

To add a label to a run from the command line, use the polyspace-access command with the -add-label option.

For instance, suppose that you use a continuous integration tool like Jenkins and that you want to associate the Jenkins build number with the project run that you upload to Polyspace Access™. The following steps show how to extract the run ID of the uploaded project run and add a label to that run by using Bash commands:

  1. Store the output of the polyspace-access -upload command to a file out.txt which you can then parse to extract the run ID of the uploaded run.

    polyspace-access $login -upload results/Folder/Path -parent-project myProject -output out.txt
    runID=$(grep -oP '(?<=RUN_ID )\d+' out.txt)
    Here:

    • The grep expression extracts the digits after the string "RUN_ID " in file out.txt. The content of that file looks similar to this:

      Upload with IMPORT_ID 1640263976711_d8b0fc8b-edfe-41c4-b718-6fd4b930e910.zip
      Upload successful for RUN_ID 14970 and PROJECT_ID 5145
      

    • $login is a variable that stores the login credentials and other connection information. To configure this variable, see Encrypt Password and Store Login Options in a Variable.

    If you use DOS commands, you can extract the run ID by using a for loop:

    for /F "tokens=5" %i in ('type out.txt ^| FIND "RUN_ID"' ) do set runID=%i
    The loop extracts the fifth space-delimited element (token) in the line that contains the string "RUN_ID". If you use the previous DOS command as part of a batch script, replace %i with %%i.

  2. Add the Jenkins build number as a label to the project run that you uploaded. You can obtain the Jenkins build number for the Jenkins environment variable BUILD_NUMBER. Run this command:

    polyspace-access $login -add-label $BUILD_NUMBER -run-id $runID
    
    To add additional labels to the project run, execute the command again for each label. You cannot specify the -add-label option more than once each time you execute the command.

    If the label that you specify for addition to a project run is already assigned to that run, the command is ignored.

To remove a label, use the polyspace-access command with the -remove-label option. For example, to remove the label you added in step 2, use this command:

polyspace-access $login -remove-label $BUILD_NUMBER -run-id $runID
If the label that you specify for removal from a project run does not match any of the labels assigned to that run, the command is ignored.