6.2 Deploying Your Changes via Azure DevOps
Published 09 September 2024
Tip: These YAML pipelines read from the Flyway project to know the locations of the target databases! When provisioning your databases, we updated the connections in Flyway Desktop to point to the newly created databases. If the pipeline encounters issues finding a database, double-check that your Flyway project has the correct and working connections to these databases. Refer back to Provisioning your Databases for more details and troubleshooting tips.
Step 1: Set Up an Azure DevOps Project (If Not Already Done)
If you haven't already set up an Azure DevOps project or imported your repository, head back to the Getting Your Repository Ready steps to ensure everything is configured properly.
Step 2: Setting Up an Azure DevOps Agent
- Provision an Agent:
- To run the pipeline, you need an Azure DevOps Agent that can access the databases you provisioned earlier. The Agent must have connectivity to these databases, whether they are on localhost, a VM, or another server.
- For more details on setting up an agent, refer to the official Azure DevOps agent documentation.
Step 3: Authenticating with Flyway (Creating a Personal Access Token)
Set Up a Personal Access Token (Click here for more details)
A valid Flyway License is required in order to authenticate Flyway within a pipeline. The most secure and industry standard way of doing this is through setting up a Personal Access token, linked to your Redgate Portal account.
- Step 1: Navigate to https://identityprovider.red-gate.com/personaltokens
- Step 2: Login with your Redgate Portal account (If you don't have one already, no problem, simply create one with your preferred email address)
- Step 3: Click '+ New Token' to create a new Personal Access Token
- Ensure you save this somewhere, like a password manager, as there's no method of seeing the token again in future.
- Step 4: Navigate to the Redgate Portal website (Where you can see all licenses linked to your account) - https://portal.red-gate.com/licenses
- Step 5: Select Flyway Enterprise (Flyway Engine) from the list (You may need to select 'Licenses on the left hand side menu)
- Step 6: Ensure the license is allocated to your email address. To do this, click '+ Allocate' > Enter your email address > Click Add User'
Note - Flyway CLI License Keys (Which start FL01) are still valid and can be used within pipelines. However, these will be deprecated in time, therefore Redgate recommends moving to PATs as described above. Reach out to the AutoPilot team at flywayap@red-gate.com if you need any further details
Step 4: Configure the Pipeline
Edit the Azure DevOps YAML Pipeline:
- Go to your Azure DevOps repository, open the
Azure DevOps
folder, and find the YAML file correct for you, you will find several YAML scripts clearly labeled with an OS suffix based on the operating system of your self-hosted runner (e.g.,windows.yml
,linux.yml
).. - The file contains important parameters for deployment. Ensure that the following are correctly set:
Key Parameters to Review:
- Connection Strings:
- Your pipeline will use the 'Environment' parameters to pass connection strings from your Flyway Desktop project. No need to manually enter JDBC URLs — just ensure that the Flyway environment placeholders are accurate and have been pushed to your repository.
Head to Provisioning Your Databases to see how this can be done!
- Your pipeline will use the 'Environment' parameters to pass connection strings from your Flyway Desktop project. No need to manually enter JDBC URLs — just ensure that the Flyway environment placeholders are accurate and have been pushed to your repository.
- Securing your Personal Access Token
- In the YAML file, you'll see two variables for FLYWAY_EMAIL & FLYWAY_TOKEN, both of which are pointing to secure variables that don't yet exist. Therefore, to keep these values secure, we must create secure variables by selecting the variables tab in the top right hand corner.
- Optional: Flyway License Key (Deprecated):
- In the YAML file, you'll also see a placeholder for the
FLYWAY_LICENSE_KEY
. This is the soon to be legacy method for Flyway CLI authentication. Should you wish to use this, simply add your Flyway CLI key to the FLYWAY_LICENSE_KEY variable, ensuring it is first uncommented (I.e remove the # at the beginning of the string)
Security Tip: While you can put the secure values inline for testing, we strongly recommend moving any secure information into a secure variable or variable group for production implementation.
SQL Authentication (if needed)
If you're using SQL Authentication instead of Windows Authentication, you will need to provide the SQL Username and Password in the YAML file. Add the following parameters under the appropriate block in the YAML file: - In the YAML file, you'll also see a placeholder for the
- Go to your Azure DevOps repository, open the
Step 5: Run the Pipeline
Create the Pipeline:
- In Azure DevOps, go to Pipelines and click New Pipeline.
- Choose Azure Repos Git and select the repository you created (by default, it’s named Flyway AutoPilot).
- Select Existing Azure Pipelines YAML File and choose the YAML file you have been using
- In Azure DevOps, go to Pipelines and click New Pipeline.
Review the YAML and Run:
- Review the file, ensure all settings (especially the connection strings and license key) are correct, and click Run.