Skip to content

Attachment commands

The opentf-ctl tool provides two commands to manage workflow attachments.

get attachments {workflow_id}

This command lists attachments produced by a workflow.

opentf-ctl get workflow 396e99ec-0fe4-4f35-8b9e-69a550a0e474
opentf-ctl get workflow 396
JOB_NAME            STEP    UUID                                    FILENAME                    TESTCASE
robot-execute-test  4       8bb0a81d-f20b-491d-bf0c-dd84a8454a4e    RobotFramework_reports.tar  test_statuses.robot
robot-execute-test  4       49dda176-25b5-4ac9-bbe6-1b64ba1c5da7    output.xml                  test_statuses.robot
<none>              <none>  68f8f5cc-36ba-439d-b15b-2c6c5e94a595_e  executionlog.txt            <none>

You can specify a partial workflow ID, as long as it is unique (if it is not, a message is displayed listing the available workflows).

The get attachments default output contains the attachments list, displaying, for each attachment, its UUID, filename, job and job step that attachment was produced by and the name of the related testcase (if any).

It is also possible to display, in addition, execution channel OS, attachment type and creation timestamp using --output=wide option. If you want to display the complete attachment data, use --output=json|yaml option:

Example: displaying workflow attachments in .yaml format

opentf-ctl get attachments 396 --output=yaml
[...]
- attachment:
    filename: RobotFramework_reports.tar
    job:
      channel_id: 903c68ea-1ccc-41a6-a311-46701b01faeb
      channel_os: linux
      job_id: 4652ffbf-b20e-4e15-9dc9-b535739fa784
      job_origin: []
      name: robot-execute-test
      namespace: default
    metadata:
      creationTimestamp: '1970-01-01T14:41:25.197874'
      name: run33
      step_id: 449d1f11-8ce9-4519-a938-ed1b2cde89b5
      step_origin:
      - 9953ecf6-d60b-4529-a1ad-7c88007b129e
      - 74aa826f-cb20-4771-a167-4642ef7259be
      step_sequence_id: 31
    parent_step:
      sequence_id: 4
      step_id: 9953ecf6-d60b-4529-a1ad-7c88007b129e
      technology: robotframework
      testcase: test_statuses.robot
    type: null
uuid: 8bb0a81d-f20b-491d-bf0c-dd84a8454a4e
- attachment:
filename: output.xml
[...]

Optional Parameters

The get attachments command allows for additional optional parameters, in no specific order, but they must follow the command if used:

--output=wide or -o wide                       # show additional information
--output=custom-columns= or -o custom-columns= #show specified information
--output=json or -o json                       # show information in JSON format
--output=yaml or -o yaml                       # show information in YAML format
--verbose or -v                                # show attachments source files and attachments related errors

You can only specify one output format at a time. Please refer to “Output formats” for more information.

Verbose Output

By default, only the successfully generated attachments are displayed in the command output. If you want to display also the source files of the workflow Allure report (i.e. the Robot Framework execution related .json and .html files) and/or the attachment generation errors, use the --verbose (or -v) flag.

Example: displaying workflow attachments in verbose mode

opentf-ctl get attachments 396 --verbose
ERROR,Failed to fetch file /home/user/not.exist: [Errno 2] No such file or directory: '/home/user/not.exist'.

ERROR,Failed to fetch file /home/user/also.not.exist: [Errno 2] No such file or directory: '/home/user/also.not.exist'.

JOB_NAME            STEP    UUID                                    FILENAME                                              TESTCASE
robot-execute-test  4       8bb0a81d-f20b-491d-bf0c-dd84a8454a4e    RobotFramework_reports.tar                            test_statuses.robot
robot-execute-test  4       49dda176-25b5-4ac9-bbe6-1b64ba1c5da7    output.xml                                            test_statuses.robot
robot-execute-test  4       b30db2bc-dc1e-419c-8450-0cad83ac99b6    2b799bd6-8cbb-404b-9b68-4b014891ae7d-result.json      test_statuses.robot
robot-execute-test  4       e112a97f-59aa-466a-8720-265ff688e414    a9bd3be9-34a6-4c90-acfe-ae3c57c80d9f-result.json      test_statuses.robot
robot-execute-test  4       f6c4631a-b2e0-48ee-b720-5024290ab579    c9227398-3fd6-45a7-9102-3a8941ae12c7-result.json      test_statuses.robot
robot-execute-test  4       22bd59b5-e022-4a72-8371-123dc4a0457d    4fa71d7c-7b7d-47a9-8761-71d764332827-attachment.html  test_statuses.robot
robot-execute-test  4       a35828f9-89f7-4fa2-b61a-bdaef4adec88    7cfc7aff-4af3-43df-bf68-33d52d37e1be-attachment.html  test_statuses.robot
robot-execute-test  4       2b863b66-f74b-4a68-a829-4680a7e6f457    7df58887-960f-4e74-b4d5-044c71658fda-attachment.html  test_statuses.robot
robot-execute-test  4       3ee669ca-a6a8-44f1-9814-52e46f802b82    b70ab9b1-bd68-4517-9b75-ba3beed1af3b-attachment.html  test_statuses.robot
<none>              <none>  68f8f5cc-36ba-439d-b15b-2c6c5e94a595_e  executionlog.txt                                      <none>

Custom View

If this optional parameter is specified, you can choose what is displayed for each known workflow attachment.

The columns definition format is as follows: name:value[,name:value]*. name is the column name in the output (NAME, TECHNOLOGY, or CREATED in the example below). value is the path to the information in the attachments schema.

The following values are supported:

  • .attachment.filename
  • .attachment.type
  • .attachment.uuid
  • .attachment.job.channel_id
  • .attachment.job.channel_os
  • .attachment.job.job_id
  • .attachment.job.job_origin
  • .attachment.job.name
  • .attachment.job.namespace
  • .attachment.metadata.creationTimestamp
  • .attachment.metadata.name
  • .attachment.metadata.step_id
  • .attachment.metadata.step_origin
  • .attachment.metadata.step_sequence_id
  • .attachment.parent_step.sequence_id
  • .attachment.parent_step.step_id
  • .attachment.parent_step.technology
  • .attachment.parent_step.testcase

opentf-ctl get attachments 396 --output=custom-columns=NAME:.attachment.filename,TECHNOLOGY:.attachment.parent_step.technology,CREATED:.attachment.metadata.creationTimestamp
NAME                        TECHNOLOGY      CREATED
RobotFramework_reports.tar  robotframework  1970-01-01T14:41:25.197874
output.xml                  robotframework  1970-01-01T14:41:25.279055
executionlog.txt            <none>          1970-01-01T14:41:25.485685

cp

This command copies a workflow attachment or workflow attachments to the specified destination. The command has the following syntax:

opentf-ctl cp {workflow_id}:({attachment_id} | {file_pattern}) /destination/path

Optional Parameters

The cp command allows for additional optional parameters, in no specific order, but they must follow the command if used:

--type= or -t=      # get only attachments of specified type

Copying single attachment

If you want to copy a single attachment, use its ID. You can specify a partial workflow ID and/or a partial attachment ID, as long as it is unique (if it is not, a message is displayed listing the available workflows or attachments).

The destination path may be a directory. In this case, the attachment is saved under attachment original name.

Example: copying the report.html to the local filesystem
opentf-ctl cp be:ab1b22b3-2cae-4f7f-8029-0afcc53da1bf /path/to/19700101_report.html
Attachment report.html (ab1b22b3-2cae-4f7f-8029-0afcc53da1bf) is downloaded as /path/to/19700101_report.html.

Warning

If you want to copy a workflow result attachment, i.e. the workflow execution log or Allure report, and to use a partial attachment ID, you must add a suffix _e for the execution log or _a for the Allure report. For example, if you want to copy the execution log, use opentf-ctl cp be:be1_e /path/to/file.ext.

Copying multiple attachments

If you need to copy multiple attachments, use a filename pattern instead of attachment ID. The destination path needs to be a directory (if it does not exist, it will be created). When multiple attachments are copied, a folder tree is created in the destination directory, matching the following schema: job/testcase/. Each attachment is copied to the job/testcase folder to which it is related to, execution log and Allure report are copied to the destination root. User-specified attachments from job and provider hooks are respectively copied in job/setup|teardown and job/testcase folder.

Example: copying all .xml attachments to the local filesystem
opentf-ctl cp be:*.xml /home/user/attachments
Attachment output.xml (5475bbf6-b588-4248-ac08-7e31b1d07049) is downloaded as /home/user/attachments/robotframework-job/1_test_backslashes_reporter.robot/output.xml.
Attachment output.xml (705a53d1-1fd5-4618-a5bc-c3101cd0d52f) is downloaded as /home/user/attachments/robotframework-job/2_test_special_chars.robot/output.xml.
Attachment calculator-report.xml (c33e4613-8063-45b8-a937-7359d66bc65b) is downloaded as /home/user/attachments/cypress-job/1_calculator.mult.ko.spec.js/calculator-report.xml.
Attachment calculator-report.xml (728a1268-c525-45d2-a7c8-e1bf3f5c9080) is downloaded as /home/user/attachments/cypress-job/2_calculator.add.ok.spec.js/calculator-report.xml.

tree /home/user/attachments
.
├── cypress-job
│   ├── 1_calculator.mult.ko.spec.js
│   │   └── calculator-report.xml
│   └── 2_calculator.add.ok.spec.js
│       └── calculator-report.xml
└── robotframework-job
    ├── 1_test_backslashes_reporter.robot
    │   └── output.xml
    └── 2_test_special_chars.robot
        └── output.xml

If you need to download only the attachments of the specified type, use --type= option. The following attachment types are currently supported:

  • application/vnd.opentestfactory.executionlog+text
  • application/vnd.opentestfactory.{provider_name}-surefire+xml (for Cucumber, Cypress, JUnit, Postman, SKF and SoapUI)
  • application/vnd.opentestfactory.robotframework-output+xml
Example: copying all Cucumber surefire-xml reports to the local filesystem

opentf-ctl cp be:* /home/user/attachments --type=*cypress-surefire*
Attachment calculator-report.xml (c33e4613-8063-45b8-a937-7359d66bc65b) is downloaded as /home/user/attachments/cypress-job/1_calculator.mult.ko.spec.js/calculator-report.xml.
Attachment calculator-report.xml (728a1268-c525-45d2-a7c8-e1bf3f5c9080) is downloaded as /home/user/attachments/cypress-job/2_calculator.add.ok.spec.js/calculator-report.xml.

tree /home/user/attachments
.
└── cypress-job
    ├── 1_calculator.mult.ko.spec.js
    │       └── calculator-report.xml
    └── 2_calculator.add.ok.spec.js
            └── calculator-report.xml