Help Center/ CodeArts Pipeline/ User Guide/ Reference/ Pipeline Contexts/ Example 2: Obtaining Artifact Information Using the Pipeline Context
Updated on 2024-12-16 GMT+08:00

Example 2: Obtaining Artifact Information Using the Pipeline Context

You can use the Build extension to generate an artifact and reference it via context in the ExecuteShellCommand job to retrieve the artifact information.

  1. Create a pipeline.
  2. Add the Build extension to Stage_1, obtain the task ID as shown in Figure 1, and set the artifact identifier to demo as shown in Figure 2.

    Figure 1 Obtaining the task ID
    Figure 2 Adding the Build extension

  3. Add the ExecuteShellCommand extension to Stage_2. Run the following commands to obtain the artifact information:

    # Obtain the download address of the artifact.
    echo ${{ jobs.JOB_xZGhF.artifacts.demo.download_url }}
    # Obtain all information about the artifact.
    echo ${{ jobs.JOB_xZGhF.artifacts.demo }}
    Figure 3 Adding the ExecuteShellCommand extension

  4. Execute the pipeline. After the execution is successful, check the printed artifact information in the log.

    Figure 4 Artifact information