migrate database first pipeline test - elyjhone23/ado-pipe GitHub Wiki

The feature you’re looking for is officially called “runtime parameters” in Azure Pipelines YAML — this is exactly what provides:

  • text inputs (string)
  • dropdown selection (values)
  • inputs shown in the “Run pipeline” UI before execution

👉 Official Microsoft doc:


✅ What the docs confirm (important for your case)

From the official docs:

  • You can ask user input at run time via parameters: ([Microsoft Learn]1)

  • Parameters appear in the Run Pipeline UI (before execution) ([Microsoft Learn]1)

  • You can define:

    • string → text input (DB name, username)
    • values: → dropdown selection (Postgres / SQL Server)
  • Parameters are evaluated before pipeline runs (template parsing) ([Microsoft Learn]1)

⚠️ Important limitation (also relevant to you):

  • Parameters cannot be secret → use variables for passwords ([Microsoft Learn]1)

✅ Example YAML matching your use case

This is a clean minimal pipeline that:

  • asks for:

    • DB name
    • username
    • database engine (dropdown)
    • SQL script
  • prints them (for your testing phase)

trigger: none

parameters:
- name: dbName
  displayName: "Database name"
  type: string
  default: "testdb"

- name: dbUser
  displayName: "Database user"
  type: string
  default: "admin"

- name: dbEngine
  displayName: "Database engine"
  type: string
  default: "postgres"
  values:
    - postgres
    - sqlserver

- name: sqlScript
  displayName: "SQL script to execute"
  type: string
  default: "SELECT 1;"

variables:
- group: db-secrets

pool:
  vmImage: ubuntu-latest

jobs:
- job: TestInputs
  steps:
  - script: |
      echo "DB Name: ${{ parameters.dbName }}"
      echo "DB User: ${{ parameters.dbUser }}"
      echo "DB Engine: ${{ parameters.dbEngine }}"
      echo "SQL Script: ${{ parameters.sqlScript }}"
      echo "Password (masked): $(dbPassword)"

✅ How it behaves in UI

When you click Run pipeline in Azure DevOps:

  • You’ll see:

    • text boxes → dbName, dbUser, sqlScript
    • dropdown → dbEngine (postgres / sqlserver)

Exactly like you described.


✅ For your migration scenario (important guidance)

Since you want to run SQL migrations:

Good approach (what you're doing)

  • Use parameters → choose DB + script
  • Use environment/self-hosted agent → run SQL tool

Better structure (next step)

Split logic:

- script: |
    if [ "${{ parameters.dbEngine }}" = "postgres" ]; then
      psql ...
    else
      sqlcmd ...
    fi

⚠️ Key pitfalls (based on docs + real usage)

  1. Passwords

    • ❌ DO NOT use parameters
    • ✅ Use secret variables or variable groups
  2. Dynamic dropdowns

    • ❌ Not supported (values must be static in YAML)
  3. Parameters location

    • Must be in main pipeline YAML (not only templates)
  4. Evaluation timing

    • Parameters are resolved before runtime
    • Variables are runtime

✅ CI vs Environment (your plan)

Your idea is valid:

  • Start with CI pipeline (manual trigger) → test inputs ✔️

  • Then move to:

    • deployment job
    • environment resource + self-hosted agent

🔥 If you want next step

I can help you build a real migration pipeline that:

  • selects environment (dev/test/prod)
  • runs .sql files from repo
  • supports Postgres + SQL Server
  • uses environment approvals

Just tell me 👍

variables:

  • group: db-secrets # ✅ correct

steps:

  • script: | echo "Password is available but masked" echo "$(dbPassword)"