Pipelines often need to write files locally to be used in subsequent steps. For instance, we may want to write a configuration file before running a particular tool. In other cases, a previous step will have written an output file and we want to read it back into an expression to perform further processing, send data to a server, or control the pipeline flow conditions.
This tutorial demonstrates basic usage of the File step module, which is used to write local files, and the
read_file() expression helper function, which is used to read local files. We will write a simple HTML file with some dynamic content. Then, we will read the file and print the content to the run output.
From the Pipelines page, click “New Pipeline”.
Two step modules will be used as part of this exercise: Debug and File.
Click on the File step. the properties sidebar will appear. There are four properties that will be edited:
Next, click on the Debug step. The properties sidebar will appear. There are 3 properties that will be edited:
read_file()helper to read the “index.html” file that was defined in the File step. The “index.html” file resides in the root directory of the agent. For more information on the
read_file()helper, see the expression reference.
Next, we’ll create a variable with some example content for the HTML body.
In the upper right corner of the builder, click “Variables”, then click “Add Variable”.
The “Edit Variable” window appears. The variable consists of 3 components:
vars.bodyexpression we used previously.
Click “Submit” to save the HTML Body variable.
To save the pipeline, click “Save”. The “Save Pipeline” dialog box will appear. Enter any desired notes about the pipeline and click “Save & Exit”.
Now we’ll run our newly created pipeline. Click the Run button in the top-left.
The Run Pipeline dialog box appears. Click the Run button at the bottom.
You should now see the run output. If successful, you should be able to see the final HTML content that was written to the file.