An artifact is a collection of files generated during a pipeline run that later jobs, stages, or pipelines can reference.
Artifacts differ from caching: use artifacts to pass build outputs between jobs or pipelines; use caching to reuse dependencies that don't change often, such as packages from a package manager.
Generate artifacts
Flow pipeline steps, such as image building and artifact uploads, generate the following artifact types:
Docker image: after an image build job completes, the Docker image is pushed to Alibaba Cloud Container Registry (ACR) or a private image registry. The artifact structure is:
{
"artifact": "yunxiao-demo", # Image name
"type": "dockerImage", # Artifact type
"dockerUrl": "registry.cn-beijing.aliyuncs.com/yunxiao/yunxiao-demo:1.0", # Image address
"dockerTag": "1.0" # Image tag
}
Flow Public Storage artifact: after a build job completes, the build output is uploaded to Flow Public Storage. The artifact structure is:
{
"artifact": "yunxiao-demo", # Artifact name
"type": "flowPublic", # Artifact type
"downloadUrl": "https://sdfdff", # Artifact download address
"md5": "dffff" # Artifact MD5
}
Reference artifacts
Flow provides three ways to reference artifacts, each suited to a different scope:
Cross-job or cross-stage within the same pipeline: the standard approach for build-then-deploy workflows within a single pipeline, including integrated CI/CD scenarios.
Cross-pipeline: used when a source pipeline generates artifacts that a target pipeline deploys — for example, a production pipeline that deploys an image validated in a pre-release pipeline. This pattern is common in CI/CD separation scenarios.
From a pipeline artifact source: used for artifact promotion — for example, after pre-release validation, the artifact is published to an artifact repository, and the production pipeline selects a specific version directly from that repository.
Example 1: Cross-job or cross-stage artifact reference within the same pipeline
The following example shows artifacts flowing between jobs within the same pipeline. The deploy_job depends on build_job completing first and references the Docker image it produces.
sources:
my_repo:
……
stages:
my_stage:
name: Build And Deploy
jobs:
build_job:
name: Image Build Job
runsOn:
group: public/ap-southeast-1
container: build-steps-public-registry.ap-southeast-1.cr.aliyuncs.com/build-steps/alinux3:latest
steps:
private_registry_docker_setup:
name: Login Docker Registry
step: DockerLogin
with:
dockerRepository: registry.cn-hangzhou.aliyuncs.com
serviceConnection: <your-service-connection-id>
docker_build_push_step:
name: Image Build and Push
step: DockerBuildPush # DockerBuildPush step will generate a docker image artifact.
with:
artifact: my_image
image: registry.cn-hangzhou.aliyuncs.com/ns/demo:1.0
dockerfilePath: Dockerfile
cacheType: remote
deploy_job:
name: Kubernetes Deploy Job
steps:
kubectl_apply:
step: KubectlApply
name: Kubectl Deploy
with:
kubernetesCluster: <your-kubernetes-id>
kubectlVersion: "1.16.4"
namespace: default
yamlPath: app-configs/manifest-app
variables:
- key: image
value: $[jobs.build_job.docker_build_push_step.artifacts.my_image] # Reference the artifact generated by the docker_build_step step, which is my-image.
The following example shows artifacts flowing across stages. The deploy_stage references the Flow Public Storage artifact produced by build_stage.
sources:
my_repo:
……
stages:
build_stage:
name: Build Stage
jobs:
build_job:
name: Build Job
runsOn:
group: public/ap-southeast-1
container: build-steps-public-registry.ap-southeast-1.cr.aliyuncs.com/build-steps/alinux3:latest
steps:
setup_java_step:
name: Setup Java SDK
step: SetupJava
with:
jdkVersion: "1.8"
mavenVersion: "3.5.2"
command_step:
name: Execute Command
step: Command
with:
run: |
mvn -B clean package -Dmaven.test.skip=true -Dautoconfig.skip
upload_artifact_step:
name: Artifact Upload
step: ArtifactUpload # ArtifactUpload step will generate a artifact.
with:
uploadType: flowPublic
artifact: "Artifacts_${PIPELINE_ID}"
filePath:
- target/
deploy_stage:
name: Deploy Stage
jobs:
deploy_job:
name: VM Deploy Job
component: VMDeploy
with:
artifact: $[stages.build_stage.build_job.upload_artifact_step.artifacts.default] # Reference the artifact generated by the upload_step step, which is default.
machineGroup: <your-machine-group-id>
artifactDownloadPath: /home/admin/app/package.tgz
executeUser: root
run: |
mkdir -p /home/admin/application/
tar zxvf /home/admin/app/package.tgz -C /home/admin/application/
sh /home/admin/application/deploy.sh restart
Example 2: Cross-pipeline artifact reference
The following example shows Pipeline A generating a Docker image and Pipeline B deploying it. This pattern is commonly used when a pre-release pipeline builds and validates an image, and a separate production pipeline deploys that same image.
Source Pipeline A
sources:
my_repo:
type: gitSample
name: Java Sample Code Source
endpoint: https://atomgit.com/flow-example/spring-boot.git
branch: master
stages:
build_stage:
name: Build Stage
jobs:
build_job:
name: Java Image Build Job
steps:
private_registry_docker_setup:
name: Login Docker Registry
step: DockerLogin
with:
dockerRepository: registry.cn-hangzhou.aliyuncs.com
serviceConnection: <your-service-connection-id>
docker_build_push_step:
name: Image Build and Push
step: DockerBuildPush
with:
artifact: my_image # Source Pipeline A build job will generate a docker image.
image: registry.cn-hangzhou.aliyuncs.com/ns/demo:1.0
dockerfilePath: Dockerfile
cacheType: remote
Target Pipeline B
sources:
pipeline_a:
type: flowPipeline
name: Source Pipeline A
flowPipeline: n86bmctmphs84icj # Source Pipeline A ID
build: lastSuccessfulBuild
triggerEvents: buildSuccess
stages:
kubectl_apply_stage:
name: Deploy Stage
jobs:
deploy_job:
name: "Kubectl Apply"
runsOn:
group: public/ap-southeast-1
container: build-steps-public-registry.ap-southeast-1.cr.aliyuncs.com/build-steps/alinux3:latest
steps:
kubectl_apply_step:
name: "Kubectl Apply"
step: "KubectlApply"
with:
kubernetesCluster: <your-kubernetes-id>
kubectlVersion: "1.27.9"
namespace: default
yamlPath: app-configs/manifest-app
variables:
- key: image
value: $[sources.pipeline_a.stages.build_stage.build_job.docker_build_push_step.artifacts.my_image] # Reference the image generated by Source Pipeline A, which is my_image.
Reference syntax
Generate artifacts
Use the build artifact upload, image build, and other steps provided by Flow to package and upload artifacts. See the steps reference for details.
Reference artifacts
All three reference syntaxes follow the same pattern: navigate the pipeline hierarchy to the artifact by name.
Cross-job referencing within the same stage: $[jobs.<job_id>.<step_id>.artifacts.<artifact>]
Cross-stage referencing within the same pipeline: $[stages.<stage_id>.<job_id>.<step_id>.artifacts.<artifact>]
Cross-pipeline referencing (the source type must be flowPipeline): $[sources.<source_id>.stages.<stage_id>.<job_id>.<step_id>.artifacts.<artifact>]