k6 archive
Create a fully self-contained test archive that can be executed identically elsewhere.Synopsis
Description
Thek6 archive command creates a tarball (.tar file) containing:
- The test script
- All imported modules and dependencies
- Test configuration and options
- Environment variables (unless excluded)
Arguments
Path to the test script file to archive
Examples
Flags
Archive output filename. Use
- to output to stdout.Do not embed any environment variables (either from
--env or the actual environment) in the archive metadataTest Configuration Flags
All standard test execution flags are available to configure the archived test:Number of virtual users
Test duration
Total iteration limit
Add execution stages
Execution segment for distributed testing
Runtime Options
Add/override environment variable with
VAR=valueInclude system environment variables
JavaScript compatibility mode
k6 run are also available. See k6 run for the complete list.
Archive Contents
A k6 archive contains:- Test Script - The main JavaScript file
- Dependencies - All imported modules and files
- Configuration - Consolidated options from all sources
- Environment Variables - Runtime environment (unless excluded)
- Metadata - Version information and execution context
Use Cases
Reproducible Testing
Create an archive to ensure the exact same test can be run later:Distributed Execution
Create archives for execution across multiple machines:CI/CD Pipelines
Archive tests in one pipeline stage, execute in another:Cloud Execution
Archives can be uploaded and executed in Grafana Cloud:Security Considerations
Environment variables may contain sensitive information like:- API keys
- Passwords
- Tokens
- Internal URLs
Exit Codes
0- Archive created successfully- Non-zero - Error occurred
See Also
- k6 run - Run a test or archive
- k6 cloud - Run tests in Grafana Cloud
- k6 inspect - Inspect an archive