Search code examples
azure-devopsmariadbgithub-actionspipelinecicd

Azure DevOps Pipeline local MariaDB


I want to migrate my github action pipeline to azure devops, unfortunally i wasn't able to find an alternative to the github action "ankane/setup-mariadb@v1". For my pipline I need to create a local mariadb with a database loaded from a .sql file. I also need to create a user for that database. This was my code in my github pipeline:

    - name: Installing MariaDB
      uses: ankane/setup-mariadb@v1
      with:
        mariadb-version: ${{ matrix.mariadb-version }}
        database: DatabaseName
    - name: Creating MariaDB User
      run: |
        sudo mysql -D DatabaseName -e "CREATE USER 'Username'@localhost IDENTIFIED BY 'Password';"
        sudo mysql -D DatabaseName -e "GRANT ALL PRIVILEGES ON DatabaseName.* TO 'Username'@localhost;"
        sudo mysql -D DatabaseName -e "FLUSH PRIVILEGES;"
    - name: Importing Database
      run: |
        sudo mysql -D DatabaseName < ./test/database.sql

Does anybody know if there is a alternative for azure devops pipelines?

Cheers,


Solution

  • Does anybody know if there is a alternative for azure devops pipelines?

    If the alternative you mentioned means some tasks in Azure DevOps pipeline can do the similar thing as 'ankane/setup-mariadb@v1' in GitHub, then the answer is NO.

    DevOps doesn't have a 'build_in' task like this, even the marketplace also doesn't have a extension to do this.

    So you have two ways:

    1, If your pipeline based on Microsoft hosted agent, everything should be set up via command:

    How to Install and Start Using MariaDB on Ubuntu 20.04

    2, If your pipeline based on self hosted agent, then you can 'set up' the environment(MariaDB) before start the pipeline. And then use it in your DevOps pipeline.