4 - Pipeline 变量参数


For your convenience, the following variables are available for your pipeline configuration scripts. During pipeline executions, these variables are replaced by metadata. You can reference them in the form of ${VAR_NAME}.

Variable NameDescription
CICD_GIT_REPO_NAMERepository name (Github organization omitted).
CICD_GIT_URLURL of the Git repository.
CICD_GIT_COMMITGit commit ID being executed.
CICD_GIT_BRANCHGit branch of this event.
CICD_GIT_REFGit reference specification of this event.
CICD_GIT_TAGGit tag name, set on tag event.
CICD_EVENTEvent that triggered the build (push, pull_request or tag).
CICD_PIPELINE_IDRancher ID for the pipeline.
CICD_EXECUTION_SEQUENCEBuild number of the pipeline.
CICD_EXECUTION_IDCombination of {CICD_PIPELINE_ID}-{CICD_EXECUTION_SEQUENCE}.
CICD_REGISTRYAddress for the Docker registry for the previous publish image step, available in the Kubernetes manifest file of a Deploy YAML step.
CICD_IMAGEName of the image built from the previous publish image step, available in the Kubernetes manifest file of a Deploy YAML step. It does not contain the image tag.Example

Full .rancher-pipeline.yml Example

  1. # example
  2. stages:
  3. - name: Build something
  4. # Conditions for stages
  5. when:
  6. branch: master
  7. event: [ push, pull_request ]
  8. # Multiple steps run concurrently
  9. steps:
  10. - runScriptConfig:
  11. image: busybox
  12. shellScript: echo ${FIRST_KEY} && echo ${ALIAS_ENV}
  13. # Set environment variables in container for the step
  14. env:
  15. FIRST_KEY: VALUE
  16. SECOND_KEY: VALUE2
  17. # Set environment variables from project secrets
  18. envFrom:
  19. - sourceName: my-secret
  20. sourceKey: secret-key
  21. targetKey: ALIAS_ENV
  22. - runScriptConfig:
  23. image: busybox
  24. shellScript: date -R
  25. # Conditions for steps
  26. when:
  27. branch: [ master, dev ]
  28. event: push
  29. - name: Publish my image
  30. steps:
  31. - publishImageConfig:
  32. dockerfilePath: ./Dockerfile
  33. buildContext: .
  34. tag: rancher/rancher:v2.0.0
  35. # Optionally push to remote registry
  36. pushRemote: true
  37. registry: reg.example.com
  38. - name: Deploy some workloads
  39. steps:
  40. - applyYamlConfig:
  41. path: ./deployment.yaml
  42. # branch conditions for the pipeline
  43. branch:
  44. include: [ master, feature/*]
  45. exlclude: [ dev ]