Zurück zum Blog
Technical

GetCookies CLI: Command-Line Consent Management for DevOps

GetCookies TeamJanuary 1, 202514 Min. Lesezeit
CLIDevOpsCI/CDDeveloperTerminal

TLDR: GetCookies CLI lets you manage domains, run scans, and check consent stats from your terminal. Perfect for CI/CD pipelines, DevOps workflows, and developers who prefer command-line over dashboards.

Read full summary A command-line interface for GetCookies that enables developers to manage cookie consent directly from the terminal. Supports domain management, cookie scanning, consent statistics, widget configuration, and integrates seamlessly with CI/CD pipelines for automated compliance monitoring. *Summary by Claude AI*
## The 3 AM Deployment Problem A DevOps engineer pushed a critical hotfix at 3 AM. The deployment succeeded, but they forgot to check if the new feature added any tracking scripts. By morning, the site had been collecting data without consent for 6 hours. Their existing workflow required logging into the dashboard, navigating to the domain, and running a scan manually. At 3 AM, that wasn't happening. What they needed: a single command in their deployment pipeline that would scan for new cookies and alert if anything unexpected appeared. ## Why a CLI for Cookie Consent? ### Developer Workflow Integration Developers live in terminals. A CLI means: - No context-switching to a dashboard - Scriptable operations - Keyboard-driven efficiency ### CI/CD Pipeline Automation Add compliance checks to your deployment: ```yaml deploy: script: - npm run build - npm run deploy - getcookie scans start $DOMAIN_ID - getcookie scans status $SCAN_ID --wait ``` ### DevOps Monitoring Integrate with existing monitoring tools: ```bash # Cron job for daily compliance check 0 6 * * * getcookie scans start prod-domain && getcookie consent stats prod-domain >> /var/log/consent-stats.log ``` ## Installation ```bash npm install -g getcookie-cli ``` Or with yarn: ```bash yarn global add getcookie-cli ``` Requires Node.js 18 or later. ## Authentication ### Login with Credentials ```bash getcookie login -e [email protected] -p yourpassword ``` Credentials are stored securely using system keychain. ### API Key Authentication For CI/CD environments, set environment variables: ```bash export GETCOOKIE_API_KEY=your_api_key ``` ### Check Login Status ```bash getcookie whoami ``` ### Logout ```bash getcookie logout ``` ## Domain Management ### List All Domains ```bash getcookie domains list ``` Output: ``` ┌──────────┬─────────────────────┬─────────────────────┐ │ ID │ Domain │ Last Scan │ ├──────────┼─────────────────────┼─────────────────────┤ │ abc12345 │ example.com │ 2025-01-15 03:00:00 │ │ def67890 │ shop.example.com │ 2025-01-14 15:30:00 │ │ ghi11111 │ blog.example.com │ - │ └──────────┴─────────────────────┴─────────────────────┘ ``` ### Add a Domain ```bash getcookie domains add example.com ``` Output: ``` ✓ Domain added! ID: abc12345 ``` ### Delete a Domain ```bash getcookie domains delete abc12345 ``` ## Cookie Scanning ### Start a Scan ```bash getcookie scans start abc12345 ``` Output: ``` ✓ Scan started! ID: scan_xyz789 ``` ### Check Scan Status ```bash getcookie scans status scan_xyz789 ``` Output: ``` Status: completed Pages: 15, Cookies: 23 ``` ### Wait for Scan Completion ```bash getcookie scans status scan_xyz789 --wait ``` Blocks until scan completes—useful for CI/CD. ### List Detected Cookies ```bash getcookie scans cookies scan_xyz789 ``` Output: ``` ┌────────────────┬────────────┬─────────────────┬─────────┐ │ Name │ Category │ Domain │ Expiry │ ├────────────────┼────────────┼─────────────────┼─────────┤ │ _ga │ analytics │ .example.com │ 730d │ │ _gid │ analytics │ .example.com │ 1d │ │ session_id │ essential │ example.com │ Session │ │ _fbp │ marketing │ .example.com │ 90d │ └────────────────┴────────────┴─────────────────┴─────────┘ ``` ## Consent Statistics ### View Consent Stats ```bash getcookie consent stats abc12345 ``` Output: ``` Total: 45,231 Accepted: 34,567 | Rejected: 10,664 Acceptance Rate: 76.4% ``` ### View Consent Logs ```bash getcookie consent logs abc12345 --limit 10 ``` Output: ``` ┌─────────────────────┬─────────┬────────────────┐ │ Time │ Consent │ Cookie │ ├─────────────────────┼─────────┼────────────────┤ │ 1/15/2025, 2:34 PM │ Yes │ analytics │ │ 1/15/2025, 2:33 PM │ No │ marketing │ │ 1/15/2025, 2:31 PM │ Yes │ all │ └─────────────────────┴─────────┴────────────────┘ ``` ## Widget Configuration ### Get Current Config ```bash getcookie widget config abc12345 ``` Output (JSON): ```json { "position": "bottom-right", "theme": "light", "primary_color": "#0066cc", "google_consent_mode": true, "iab_tcf_enabled": false } ``` ### Get Embed Snippet ```bash getcookie widget snippet abc12345 ``` Output: ```html ``` ## CI/CD Integration Examples ### GitHub Actions ```yaml name: Deploy with Compliance Check on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Deploy run: npm run deploy - name: Install GetCookie CLI run: npm install -g getcookie-cli - name: Run Compliance Scan env: GETCOOKIE_API_KEY: ${{ secrets.GETCOOKIE_API_KEY }} run: | SCAN_ID=$(getcookie scans start ${{ vars.DOMAIN_ID }} --json | jq -r '.scan_id') getcookie scans status $SCAN_ID --wait COOKIES=$(getcookie scans cookies $SCAN_ID --json | jq '.items | length') echo "Detected $COOKIES cookies" - name: Check for Unclassified Cookies run: | UNCLASSIFIED=$(getcookie scans cookies $SCAN_ID --json | jq '[.items[] | select(.category == "unclassified")] | length') if [ "$UNCLASSIFIED" -gt 0 ]; then echo "::warning::Found $UNCLASSIFIED unclassified cookies" fi ``` ### GitLab CI ```yaml stages: - deploy - compliance deploy: stage: deploy script: - npm run deploy compliance-scan: stage: compliance image: node:20 script: - npm install -g getcookie-cli - getcookie scans start $DOMAIN_ID - getcookie consent stats $DOMAIN_ID variables: GETCOOKIE_API_KEY: $GETCOOKIE_API_KEY ``` ### Jenkins Pipeline ```groovy pipeline { agent any environment { GETCOOKIE_API_KEY = credentials('getcookie-api-key') } stages { stage('Deploy') { steps { sh 'npm run deploy' } } stage('Compliance Check') { steps { sh 'npm install -g getcookie-cli' sh 'getcookie scans start ${DOMAIN_ID}' sh 'getcookie consent stats ${DOMAIN_ID}' } } } } ``` ## Scripting Examples ### Daily Compliance Report ```bash #!/bin/bash # daily-compliance-report.sh DOMAINS=$(getcookie domains list --json | jq -r '.items[].id') echo "Daily Compliance Report - $(date)" echo "================================" for DOMAIN_ID in $DOMAINS; do DOMAIN=$(getcookie domains list --json | jq -r ".items[] | select(.id==\"$DOMAIN_ID\") | .domain") STATS=$(getcookie consent stats $DOMAIN_ID --json) RATE=$(echo $STATS | jq -r '.acceptance_rate * 100 | floor') TOTAL=$(echo $STATS | jq -r '.total_consents') echo "$DOMAIN: $RATE% acceptance ($TOTAL total)" done ``` ### New Cookie Alert ```bash #!/bin/bash # check-new-cookies.sh SCAN_ID=$(getcookie scans start $DOMAIN_ID --json | jq -r '.scan_id') getcookie scans status $SCAN_ID --wait UNCLASSIFIED=$(getcookie scans cookies $SCAN_ID --json | jq '[.items[] | select(.category == "unclassified")]') COUNT=$(echo $UNCLASSIFIED | jq 'length') if [ "$COUNT" -gt 0 ]; then echo "⚠️ Found $COUNT unclassified cookies:" echo $UNCLASSIFIED | jq -r '.[].name' # Send Slack notification curl -X POST $SLACK_WEBHOOK -d "{\"text\": \"Found $COUNT unclassified cookies on $DOMAIN\"}" fi ``` ## JSON Output All commands support `--json` flag for machine-readable output: ```bash getcookie domains list --json getcookie scans cookies scan_xyz --json getcookie consent stats domain_id --json ``` This enables easy integration with `jq`, scripts, and other tools. ## Configuration ### Set API URL For self-hosted or staging environments: ```bash getcookie config set apiUrl https://staging.getcookie.app ``` ### View Configuration ```bash getcookie config list ``` ## Error Handling The CLI exits with appropriate codes: - `0`: Success - `1`: General error - `2`: Authentication error - `3`: Validation error Use in scripts: ```bash if ! getcookie scans start $DOMAIN_ID; then echo "Scan failed" exit 1 fi ``` ## Getting Started 1. Install: `npm install -g getcookie-cli` 2. Login: `getcookie login -e [email protected] -p password` 3. List domains: `getcookie domains list` 4. Run a scan: `getcookie scans start ` 5. Check results: `getcookie scans cookies ` Cookie compliance belongs in your development workflow—not as an afterthought in a dashboard.

Häufig gestellte Fragen

What can I do with the CLI?
The CLI supports domain management (list, add, delete), cookie scanning (start, status, results), consent statistics, and widget configuration—all from your terminal.
How do I use the CLI in CI/CD pipelines?
Set the GETCOOKIE_API_KEY environment variable and use commands like `getcookie scans start` and `getcookie scans status --wait` in your deployment scripts.
Does the CLI support JSON output?
Yes, all commands support --json flag for machine-readable output, making it easy to integrate with scripts and other tools.
G

GetCookies Team

Autor bei GetCookies, spezialisiert auf Datenschutz-Compliance, Einwilligungsmanagement und Optimierung von digitalem Marketing.

Bereit, Cookie-Einwilligung zu vereinfachen?

GetCookies macht DSGVO, CCPA und globale Datenschutz-Compliance mühelos. Starten Sie heute.