Sharing and Versioning

Artifact Management

4. Sharing and Versioning

Artifacts facilitate collaboration and make build outputs traceable across teams and projects.

4.1 Publishing Artifacts

Publish artifacts securely for consumption by other projects or teams.

Artifact Publishing

Use GitLab job artifacts to publish and share build outputs with controlled access.

  • Define Artifacts in the CI/CD Pipeline:

    Specify the job artifacts to be stored by GitLab in your .gitlab-ci.yml file.

    
    build: 
      stage: build 
      script: 
        - make build 
      artifacts: 
        paths: 
          - build/ 
        expire_in: 30 days
    
    • paths: Specifies the files or directories to be stored as artifacts.
    • expire_in: Sets the duration for which the artifacts are retained.
  • Control Access to Artifacts:

    • Ensure that your project visibility and member permissions are appropriately set to control access to the published artifacts.
    • Navigate to Project > Settings > General > Visibility, project features, permissions to set the appropriate visibility level (private, internal, or public) and manage access controls.

4.2 Versioning Artifacts

Manage artifact versions to track changes and facilitate rollback if necessary.

Artifact Versioning Strategy

Implement versioning conventions and tags in CI/CD pipelines for easy tracking and management.

variables:
  VERSION: "1.0.$CI_PIPELINE_ID"

build:
  stage: build
  script:
    - make build
    - mv build build-$VERSION
  artifacts:
    paths:
      - build-$VERSION/
    expire_in: 30 days

Optional feedback