

Amazon CodeCatalyst is no longer open to new customers. Existing customers can continue to use the service as normal. For more information, see [How to migrate from CodeCatalyst](migration.md).

# Examples of artifacts
<a name="workflows-working-artifacts-ex"></a>

The following examples show how to output, input, and reference artifacts in the Amazon CodeCatalyst workflow definition file.

**Topics**
+ [Example: Outputting an artifact](#workflows-working-artifacts-ex-basic)
+ [Example: Inputting an artifact generated by another action](#workflows-working-artifacts-ex-ref)
+ [Example: Referencing files in multiple artifacts](#workflows-working-artifacts-ex-ref-file)
+ [Example: Referencing a file in a single artifact](#workflows-working-artifacts-ex-ref-file-one)
+ [Example: Referencing a file in an artifact when a WorkflowSource is present](#workflows-working-artifacts-ex-ref-file-wf-source)
+ [Example: Referencing a file in an artifact when an action group is present](#workflows-working-artifacts-ex-groups)

## Example: Outputting an artifact
<a name="workflows-working-artifacts-ex-basic"></a>

The following example shows how to output an artifact that includes two .jar files.

```
Actions:
  Build:
    Identifier: aws/build@v1
    Outputs:
      Artifacts:
        - Name: ARTIFACT1
          Files:
            - build-output/file1.jar
            - build-output/file2.jar
```

## Example: Inputting an artifact generated by another action
<a name="workflows-working-artifacts-ex-ref"></a>

The following example shows you how to output an artifact called `ARTIFACT4` in `BuildActionA`, and input it into `BuildActionB`.

```
Actions:
  BuildActionA:
    Identifier: aws/build@v1  
    Outputs:
      Artifacts:
        - Name: ARTIFACT4
          Files:
            - build-output/file1.jar
            - build-output/file2.jar
  BuildActionB:
    Identifier: aws/build@v1  
    Inputs:
      Artifacts:
        - ARTIFACT4
    Configuration:
```

## Example: Referencing files in multiple artifacts
<a name="workflows-working-artifacts-ex-ref-file"></a>

The following example shows you how to output two artifacts named `ART5` and `ART6` in `BuildActionC`, and then reference two files named `file5.txt` (in artifact `ART5`) and `file6.txt` (in artifact `ART6`) in `BuildActionD` (under `Steps`).

**Note**  
For more information on referencing files, see [Referencing files in an artifact](workflows-working-artifacts-refer-files.md).

**Note**  
Although the example shows the `$CATALYST_SOURCE_DIR_ART5` prefix being used, you could omit it. This is because `ART5` is the *primary input*. To learn more about the primary input, see [Referencing files in an artifact](workflows-working-artifacts-refer-files.md). 

```
Actions:
  BuildActionC:
    Identifier: aws/build@v1  
    Outputs:
      Artifacts:
        - Name: ART5
          Files:
            - build-output/file5.txt
        - Name: ART6
          Files:
            - build-output/file6.txt
  BuildActionD:
    Identifier: aws/build@v1  
    Inputs:
      Artifacts:
        - ART5
        - ART6
    Configuration:
      Steps:
        - run: cd $CATALYST_SOURCE_DIR_ART5/build-output && cat file5.txt
        - run: cd $CATALYST_SOURCE_DIR_ART6/build-output && cat file6.txt
```

## Example: Referencing a file in a single artifact
<a name="workflows-working-artifacts-ex-ref-file-one"></a>

The following example shows you how to output one artifact named `ART7` in `BuildActionE`, and then reference `file7.txt` (in artifact `ART7`) in `BuildActionF` (under `Steps`).

Notice how the reference does not require the `$CATALYST_SOURCE_DIR_`*artifact-name* prefix in front of the `build-output` directory as it did in [Example: Referencing files in multiple artifacts](#workflows-working-artifacts-ex-ref-file). This is because there is only one item specified under `Inputs`.

**Note**  
For more information on referencing files, see [Referencing files in an artifact](workflows-working-artifacts-refer-files.md).

```
Actions:
  BuildActionE:
    Identifier: aws/build@v1  
    Outputs:
      Artifacts:
        - Name: ART7
          Files:
            - build-output/file7.txt
  BuildActionF:
    Identifier: aws/build@v1  
    Inputs:
      Artifacts:
        - ART7
    Configuration:
      Steps:
        - run: cd build-output && cat file7.txt
```

## Example: Referencing a file in an artifact when a WorkflowSource is present
<a name="workflows-working-artifacts-ex-ref-file-wf-source"></a>

The following example shows you how to output one artifact named `ART8` in `BuildActionG`, and then reference `file8.txt` (in artifact `ART8`) in `BuildActionH` (under `Steps`).

Notice how the reference requires the `$CATALYST_SOURCE_DIR_`*artifact-name* prefix, as it did in [Example: Referencing files in multiple artifacts](#workflows-working-artifacts-ex-ref-file). This is because there are multiple items specified under `Inputs` (a source and an artifact), so you need the prefix to indicate where to look for the file.

**Note**  
For more information on referencing files, see [Referencing files in an artifact](workflows-working-artifacts-refer-files.md).

```
Actions:
  BuildActionG:
    Identifier: aws/build@v1  
    Outputs:
      Artifacts:
        - Name: ART8
          Files:
            - build-output/file8.txt
  BuildActionH:
    Identifier: aws/build@v1  
    Inputs:
      Sources:
        - WorkflowSource
      Artifacts:
        - ART8
    Configuration:
      Steps:
        - run: cd $CATALYST_SOURCE_DIR_ART8/build-output && cat file8.txt
```

## Example: Referencing a file in an artifact when an action group is present
<a name="workflows-working-artifacts-ex-groups"></a>

The following example shows you how to output an artifact named `ART9` in `ActionGroup1`, `ActionI`, and then reference `file9.txt` (in artifact `ART9`) in `ActionJ`.

For more information on referencing files, see [Referencing files in an artifact](workflows-working-artifacts-refer-files.md).

```
Actions:
  ActionGroup1:
    Actions:
      ActionI:
        Identifier: aws/build@v1
        Outputs:
          Artifacts:
            - Name: ART9
              Files:
                - build-output/file9.yml
      ActionJ:
        Identifier: aws/cfn-deploy@v1 
        Inputs:
          Sources:
            - WorkflowSource
          Artifacts:
            - ART9
        Configuration:
          template: /artifacts/ActionGroup1@ActionJ/ART9/build-output/file9.yml
```