Main Content

polyspace-access -add-label

Add label to project run

    Description

    The system command polyspace-access -add-label adds a label to a project run in Polyspace® Access™ specified using a run ID.

    polyspace-access -add-label <label> -run-id <runID> -host <hostname> [login options] [output options] adds a label to the project run specified with <runID>. Use labels to identify project runs of interest, or to associate a run with a specific branch or continuous integration build job. For more information about project labels, see Manage Labels at the Command Line.

    example

    Examples

    collapse all

    Extract the run ID of the uploaded project run and add a label to that run. Use a continuous integration tool such as Jenkins® to associate the Jenkins build number with the project run that you upload to Polyspace Access.

    Store the output of the polyspace-access -upload command to a file out.txt and extract the run ID of the uploaded run.

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

    The grep expression extracts the digits after the string "RUN_ID" in the file out.txt. The content of out.txt 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
    

    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 this DOS command as part of a batch script, replace %i with %%i.

    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 -add-label $BUILD_NUMBER -run-id $runID ^
    -host myAccessServer
    
    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 a project run is already assigned to that run, the command is ignored.

    Input Arguments

    collapse all

    Manage Project Labels

    Project run label to add to the project run that you specify with option -run-id, specified as a string. If the label includes spaces, use double quotes.

    Example: testing_branch

    Example: "testing branch"

    Run ID of the project run to add a label to, specified as a string. To view the latest run IDs for a project, use the command polyspace-access -list-project. To view the run IDs of all the project runs for a specific project, use the command polyspace-access -list-runs.

    Example: -run-id 1234

    Connection Configuration

    Polyspace Access machine hostname that you specify in the URL of the Polyspace Access interface, such as https://hostname:portNumber/metrics/index.html. If you are unsure about which hostname to use, contact your Polyspace Access administrator.

    You must specify a hostname with all polyspace-access commands, except the -generate-migration-commands and -encrypt-password commands.

    Example: -host myAccessServer

    Port number that you specify in the URL of the Polyspace Access interface, such as https://hostname:portNumber/metrics/index.html. If you are unsure about which port number to use, contact your Polyspace Access administrator.

    HTTP protocol used to access Polyspace Access, specified as http or https.

    Full path to the text file where you store your login credentials. Use this option if you use a command that requires your Polyspace Access credentials in a script but you do not want to store your credentials in that script. While the script runs, someone inspecting currently running processes cannot see your credentials.

    You can store only one set of credentials in the file, either as -login and -encrypted-password entries on separate lines, for instance:

    -login jsmith
    -encrypted-password LAMMMEACDMKEFELKMNDCONEAPECEEKPL
    You can also store credentials as an -api-key entry:
    -api-key keyValue123
    Make sure that the file where you store your credentials is UTF-8 encoded and that you restrict the read and write permissions on the file. For example, to restrict read and write permissions on file login.txt in Linux®, use this command:
    chmod go-rwx login.txt

    API key you use as a login credential instead of providing your login and encrypted password. To assign an API key to a user, see Configure User Manager or contact your Polyspace Access administrator.

    Use the API key if you use a command that requires your Polyspace Access login credentials as part of an automation script with a CI tool such as Jenkins. If a user updates their password, you do not need to update the API key associated with that user in your scripts.

    It is recommended that you store the API key in a text file and pass that file to the command by using the -credentials-file option.

    Login username that you use to interact with Polyspace Access.

    Use the options -login and -encryped-password together. If you do not use these two options together, you are prompted to enter your credentials at the command line, unless you use -api-key.

    Login password you use to interact with Polyspace Access. <ENCRYPTED_PASSWORD> is the output of the polyspace-access -encrypt-password command.

    Use the options -login and -encryped-password together. If you do not use these two options together, you are prompted to enter your credentials at the command line, unless you use the -api-key option.

    Number of times the polyspace-access command retries to upload results when you upload from a client machine to the server machine that hosts Polyspace Access before failing. Specify this option to retry the upload command in the event of sporadic network outages. The command waits 10 seconds between retries.

    Full path to command outputs.

    Path to the folder for storing temporary files generated by polyspace-access commands. The default folder path depends on your platform:

    • Windows — C:\Users\%username%\AppData\Local\Temp\ps_results_server

    • Linux — tmp/ps_results_server

    File path where you store the command output log. By default the command does not generate a log file.

    Version History

    Introduced in R2019a