GeoServer CLI Tools Stable

The official command-line interface for managing GeoServer instances, automating geospatial workflows, and orchestrating spatial data pipelines. Designed for DevOps, GIS engineers, and automation-first teams.

๐Ÿ“ฆ Package Manager Support

Available via npm, Homebrew, apt, and direct binary distribution. Supports Windows, macOS, and Linux.

Install via npm

Terminal
$ npm install -g @geoserver/cli
โœ“ Installed geoserver@2.4.1

Install via Homebrew (macOS/Linux)

Terminal
$ brew tap geoserver/tools
$ brew install geoserver-cli

Direct Binary

Download pre-compiled binaries from the releases page. Extract and add the binary to your system PATH.

Quick Start

Get up and running in three steps. The CLI caches credentials securely and supports context switching for multi-tenant environments.

1. Authenticate

Terminal
$ geoserver login --url https://gis.example.com --user admin --pass your-password
โœ“ Authenticated to gis.example.com (Profile: default)

2. Publish a Layer

Terminal
$ geoserver layers create --workspace hydrology --name river_network --type shp --src ./data/rivers.shp
โœ“ Uploaded 1.2MB (2,403 features)
โœ“ Published WMS/WFS endpoint
๐Ÿ”— https://gis.example.com/geoserver/wms?LAYERS=hydrology:river_network

Core Commands

All commands follow the pattern: geoserver <command> [subcommand] [options]

Data Management

CommandDescriptionExample
layers createPublish a new vector/raster layergeoserver layers create --name lakes --src lakes.geojson
layers updateRefresh layer data or stylinggeoserver layers update --name lakes --style dark_water
layers deleteRemove a layer and its storegeoserver layers delete --name lakes --force
data importBatch import multiple formatsgeoserver data import ./datasets/ --recursive
data exportExtract features to filegeoserver data export --query "POP > 10000" --out cities.csv

Administration

CommandDescriptionExample
workspaces lsList all workspacesgeoserver workspaces ls --json
stores addCreate database/file storegeoserver stores add --type postgis --conn "host=db user=gis dbname=spatial"
styles applyAttach SLD/SE stylegeoserver styles apply --layer roads --style-file custom.sld
security syncSynchronize RBAC rulesgeoserver security sync --config rbac.yaml

Utility

CommandDescriptionExample
statusCheck instance health & quotasgeoserver status
cache purgeClean tile/feature cachegeoserver cache purge --layer topo --recursive
validateCheck data/schema compliancegeoserver validate ./input/ --strict

Global Flags & Options

Flags Reference
-h, --help        Show usage information
-v, --verbose     Enable debug logging
--json            Output machine-readable JSON
--dry-run         Preview changes without executing
--timeout ms      API request timeout (default: 30000)
--profile name    Switch authentication context

Configuration

The CLI stores configuration in ~/.geoserver/config.json. Environment variables take precedence.

Environment Variables

VariableDescriptionExample
GEOSERVER_URLDefault instance endpointhttps://api.geoserver.com
GEOSERVER_TOKENAPI key / JWT tokengsv_8x92k3...
GEOSERVER_TIMEOUTDefault request timeout60000
GEOSERVER_VERIFY_SSLDisable SSL verificationfalse
โš ๏ธ Security Note

Never commit config.json or plaintext credentials to version control. Use environment variables or secret managers in CI/CD pipelines.

Real-World Examples

CI/CD Pipeline Deployment

GitHub Actions
- name: Deploy GeoLayers
  run: "geoserver login --token $GEOSERVER_TOKEN && geoserver data import ./output/ --auto-publish"

Batch Style Update

Bash Script
for layer in rivers highways cities; do
  geoserver layers update --name $layer --style new_theme_2025
done
echo "โœ… Batch update complete"

Export to GeoPackage

Terminal
$ geoserver data export --workspace survey --layers parcels,roads --format gpkg --out export.gpkg
โœ“ Exported 2 layers (4.8MB)

Troubleshooting

  • Authentication Failed: Check GEOSERVER_TOKEN expiration or run geoserver login --refresh
  • Timeout Errors: Increase timeout with --timeout 60000 or check network latency
  • CRS Mismatch: Use geoserver validate --strict to catch projection issues before upload
  • Permission Denied: Verify RBAC roles via geoserver security sync --dry-run
๐Ÿ› Report an Issue

CLI bugs and feature requests are tracked on GitHub. Include geoserver --verbose output when reporting.