Skip to content

Instantly share code, notes, and snippets.

@bzuillsmith
Created December 22, 2022 18:02
Show Gist options
  • Save bzuillsmith/bcd5c5e7d0459a8572260c1ac272317f to your computer and use it in GitHub Desktop.
Save bzuillsmith/bcd5c5e7d0459a8572260c1ac272317f to your computer and use it in GitHub Desktop.
Pipeline Script: Install mongosh and initialize a test DB
script:
  # Install mongosh
  - >
    curl -fSsL --output mongosh.tgz https://downloads.mongodb.com/compass/mongosh-1.6.1-linux-x64.tgz &&
    tar -xf mongosh.tgz -C /usr/share &&
    rm mongosh.tgz
  # Initialize test db
  - /usr/share/mongosh-1.6.1-linux-x64/bin/mongosh mongodb://root:[email protected]:27017  -f scripts/init.js
  # Run tests
  - dotnet test
services:
  - mongodb

For Bitbucket Pipelines, don't forget to declare your mongodb service like the following

definitions:
  services:
    mongodb:
      image: mongo:5.0
      environment:
        MONGO_INITDB_ROOT_USERNAME: root
        MONGO_INITDB_ROOT_PASSWORD: root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment