Sobes.tech
Middle

How do instructions for creating artifacts work, what do they represent, and where are the results stored?

sobes.tech AI

Answer from AI

Instructions for creating artifacts (builds) are usually scripts or configuration files that describe the sequence of steps necessary for building, compiling, packaging, and preparing a software product or its components.

They can be implemented in various ways:

  • Makefile: A traditional tool for automating project builds based on dependencies.
  • Scripts in various languages: Bash, Python, Groovy (for Jenkins), PowerShell, and other scripting languages.
  • Configuration formats: YAML (for GitLab CI, GitHub Actions, Azure DevOps Pipelines), JSON (rarely for building, more for metadata), XML (for Maven).

Examples of formats:

# Example Makefile
build:
	gcc main.c -o myapp
	zip myapp.zip myapp
# Example .gitlab-ci.yml
build_job:
  stage: build
  script:
    - gcc main.c -o myapp
    - zip myapp.zip myapp
  artifacts:
    paths:
      - myapp.zip
# Example Bash script
#!/bin/bash
gcc main.c -o myapp
zip myapp.zip myapp

Instructions define:

  1. Preliminary steps: Obtaining source code (pull from repository), installing dependencies.
  2. Main build steps: Compilation, linking, running tests.
  3. Packaging: Creating archives, container images, installers.
  4. Post-build steps: Signing artifacts, publishing.

The resulting artifacts are stored in specialized artifact repositories. These are centralized storage locations designed for storing and managing binary files and other build outputs. Examples include:

  • Nexus Repository Manager: Supports various artifact types (Maven, npm, Docker, NuGet, etc.).
  • JFrog Artifactory: Similar to Nexus, multi-type repository.
  • Docker Registry: Specialized for storing Docker images (Docker Hub, GitLab Container Registry, Azure Container Registry).
  • S3-compatible storage: Amazon S3, MinIO, used for general file storage, including artifacts, sometimes with additional tools for indexing.

Storing in artifact repositories provides versioning, access control, ease of deployment, and integration with other CI/CD tools. This ensures that the artifacts used during deployment are exactly those that were successfully built and tested.