Environment Lifecycle
Day-to-day tasks for creating, deploying, updating, stopping, and deleting environments through Jenkins jobs.
Templates
-
Location:
shared-library/resources/templates/<service>/ -
Contents:
-
<service>.yaml— Docker Compose service definition. -
.env— default variables for the service. -
configs/— optional extra files mounted into containers.
-
-
Dependencies: optional
dependencies.yamlauto-generatesdepends_onrelationships.
Create an Environment
-
Jenkins →
QA-Environments/Create-Environment. -
First run: click Build Now to prime parameters, then Build with Parameters.
-
Parameters:
-
Environment name:
auto(generates friendly slug) or custom. -
TTL: e.g.,
1w. -
Services: choose one or more templates.
-
Variables: override defaults as needed.
-
-
Result: rendered artifacts under
/var/jenkins_home/qa-data/envs/<env>/:-
docker-compose.yml -
.env -
<service>.env -
meta.json(services, status, ttl, created_by, timestamps)
-
Deploy to an Agent
-
Jenkins →
QA-Environments/Deploy-Environment. -
Select target environment; agent label is auto-detected from
meta.jsonwhen available. -
Pipeline stashes files from master, unstashes on the agent, and runs
docker compose up -d. -
meta.jsonis updated with runner and deployment status.
Update or Reconfigure
-
Edit parameters or templates, then run
QA-Environments/Update-Environment. -
Pipeline creates a backup
docker-compose.yml.backup-*on the agent. -
Re-renders templates, reapplies Compose changes, and updates metadata.
Stop vs Delete
-
Stop:
QA-Environments/Stop-Environment— stops containers but retains files and volumes. -
Delete:
QA-Environments/Delete-Environment— removes containers, network, volumes, and files; use with caution.
TTL and Cleanup
-
TTL is stored in
meta.jsonper environment. -
Cleanup jobs scan for expired TTL and remove corresponding environments to free resources.
-
@tmpJenkins workspaces are automatically filtered; leftover temp dirs can be pruned withutils.cleanupTempEnvDirs().
Backup and Restore
-
Before updates, Compose files are backed up on the agent as
docker-compose.yml.backup-*. -
To restore manually:
cd /opt/qa-envs/<env>/ cp docker-compose.yml.backup-<ts> docker-compose.yml docker compose up -d