

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在相关步骤中使用步骤中的文件
<a name="using-files-output-from-a-step-in-a-dependent-step"></a>

此示例说明了作业中的一个步骤如何访问其在同一作业中依赖的步骤的输出。

 为了使一个步骤的输出可供另一个步骤使用，Deadline Cloud 在会话中添加了其他操作，以便在会话中运行任务之前下载这些输出。您可以通过将这些步骤声明为需要使用输出的步骤的依赖项来告诉它要从哪些步骤下载输出。

在此示例中使用`job_attachments_devguide_output`任务包。首先，在您的 AWS CloudShell 环境中从 Deadline Cloud 示例 GitHub存储库的克隆版本中制作一份副本。对其进行修改以添加一个依赖步骤，该步骤仅在现有步骤之后运行并使用该步骤的输出：

```
cp -r deadline-cloud-samples/job_bundles/job_attachments_devguide_output ~/

cat >> job_attachments_devguide_output/template.yaml << EOF
- name: DependentStep
  dependencies:
  - dependsOn: Step
  script:
    actions:
      onRun:
        command: /bin/cat
        args:
        - "{{Param.OutputDir}}/output.txt"
EOF
```

 使用此修改后的任务包创建的作业以两个独立的会话形式运行，一个用于步骤 “步骤” 中的任务，另一个用于步骤 “DependentStep” 中的任务。

首先在 CloudShell 选项卡中启动 Deadline Cloud 工作器代理。让所有先前提交的作业完成运行，然后从日志目录中删除作业日志：

```
rm -rf ~/demoenv-logs/queue-*
```

 接下来，使用修改后的任务包提交`job_attachments_devguide_output`作业。等待它在 CloudShell 环境中的工作器上完成运行。查看这两个会话的日志：

```
# Change the value of FARM_ID to your farm's identifier
FARM_ID=farm-{{00112233445566778899aabbccddeeff}}
# Change the value of QUEUE1_ID to queue Q1's identifier
QUEUE1_ID=queue-{{00112233445566778899aabbccddeeff}}
# Change the value of WSALL_ID to the identifier of the WSAll storage profile
WSALL_ID=sp-{{00112233445566778899aabbccddeeff}}

deadline config set settings.storage_profile_id $WSALL_ID

deadline bundle submit --farm-id $FARM_ID --queue-id $QUEUE1_ID ./job_attachments_devguide_output

# Wait for the job to finish running, and then:

cat demoenv-logs/queue-*/session-*
```

 在名为的步骤中任务的会话日志中`DependentStep`，运行了两个单独的下载操作：

```
2024-07-17 02:52:05,666 INFO ==============================================
2024-07-17 02:52:05,666 INFO --------- Job Attachments Download for Job
2024-07-17 02:52:05,667 INFO ==============================================
2024-07-17 02:52:05,667 INFO Syncing inputs using Job Attachments
2024-07-17 02:52:05,928 INFO Downloaded 207.0 B / 207.0 B of 1 file (Transfer rate: 0.0 B/s)
2024-07-17 02:52:05,929 INFO Summary Statistics for file downloads:
Processed 1 file totaling 207.0 B.
Skipped re-processing 0 files totaling 0.0 B.
Total processing time of 0.03954 seconds at 5.23 KB/s.

2024-07-17 02:52:05,979 INFO 
2024-07-17 02:52:05,979 INFO ==============================================
2024-07-17 02:52:05,979 INFO --------- Job Attachments Download for Step
2024-07-17 02:52:05,979 INFO ==============================================
2024-07-17 02:52:05,980 INFO Syncing inputs using Job Attachments
2024-07-17 02:52:06,133 INFO Downloaded 117.0 B / 117.0 B of 1 file (Transfer rate: 0.0 B/s)
2024-07-17 02:52:06,134 INFO Summary Statistics for file downloads:
Processed 1 file totaling 117.0 B.
Skipped re-processing 0 files totaling 0.0 B.
Total processing time of 0.03227 seconds at 3.62 KB/s.
```

 第一个操作会下载名为 “Step” 的步骤所使用的`script.sh`文件。第二个操作会下载该步骤的输出。Deadline Cloud 使用该步骤生成的输出清单作为输入清单来确定要下载哪些文件。

 在同一条日志的后面，你可以看到名为 DependentStep “” 的步骤的输出：

```
2024-07-17 02:52:06,213 INFO Output:
2024-07-17 02:52:06,216 INFO Script location: /sessions/session-{{5b33f}}/assetroot-{{3751a}}/script.sh
```