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
string
required
Path to the test script file to archive
Examples
Flags
string
default:"archive.tar"
Archive output filename. Use
- to output to stdout.boolean
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:int
default:"1"
Number of virtual users
duration
Test duration
int
Total iteration limit
string[]
Add execution stages
string
Execution segment for distributed testing
Runtime Options
string[]
Add/override environment variable with
VAR=valueboolean
Include system environment variables
string
default:"extended"
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