Way to use input values dynamically located in file in the repo - Azure DevOps

tarun k 280 Reputation points
2025-06-17T04:26:16.28+00:00

I have UN and PW and other input values in the text file and that text file is there in repo. I will have to pass that values dynamically

please suggest how we can do this..

Azure DevOps
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 4,165 Reputation points Microsoft External Staff Moderator
    2025-06-17T08:34:04.47+00:00

    Hi tarun k

    yes, the above steps still works even if the liquibase.properties file is in the repo.

    In your repo, keep the liquibase.properties file like this:

    liquibase.loglevel=debug
       username=${DB_USERNAME}
       password=${DB_PASSWORD}
       changeLogFile=changeset_master.xml
       url=test.com
    

    And then define the YAML File which I mentioned as above.

    Hope this helps!

    Please Let me know if you have any queries.

    If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.


  2. Durga Reshma Malthi 4,165 Reputation points Microsoft External Staff Moderator
    2025-06-17T08:13:56.0266667+00:00

    Hi tarun k

    To dynamically inject the username and password into your Liquibase properties file during pipeline execution, you can use Azure DevOps pipeline variables.

    Please follow the below steps to resolve this issue:

    1. In your Azure DevOps pipeline, you can define variables for username and password. Go to Pipelines -> Select your Pipeline -> Edit -> Variables -> Add variable. Make sure to mark the password parameter as secret in the pipeline definition. User's image
    2. Create a properties file (e.g., liquibase.properties) in your repository with the following content:
         liquibase.loglevel=debug
         username=$(username)
         password=$(password)
         changeLogFile=changeset_master.xml
         url=test.com
      
    3. YAML file:
         trigger:
         - main
         pool:
           vmImage: 'ubuntu-latest'
         variables:
           username: ''
           password: ''
         parameters:
           - name: username
             type: string
             default: ''
             displayName: 'Enter Username'
           - name: password
             type: string
             default: ''
             displayName: 'Enter Password'
             isSecret: true
         jobs:
         - job: LiquibaseJob
           steps:
           - checkout: self
           - script: |
               echo "Updating properties file with dynamic values"
               sed -i "s/username=.*/username=$(username)/" liquibase.properties
               sed -i "s/password=.*/password=$(password)/" liquibase.properties
             displayName: 'Update properties file'
           - script: |
               echo "Running Liquibase commands"
               # Add your Liquibase command here, e.g.:
               # liquibase --changeLogFile=changeset_master.xml update
             displayName: 'Run Liquibase'
      
    4. Alternatively, you can try the below YAML file:
      In your liquibase.properties file (in repo):
         liquibase.loglevel=debug
         username=${DB_USERNAME}
         password=${DB_PASSWORD}
         changeLogFile=changeset_master.xml
         url=test.com
      
         trigger:
         - main
         variables:
           # These will be passed at runtime or set as secret variables
           DB_USERNAME: $(username)
           DB_PASSWORD: $(password)
         stages:
         - stage: LiquibaseUpdate
           displayName: 'Run Liquibase Update'
           jobs:
           - job: RunLiquibase
             displayName: 'Execute Liquibase'
             pool:
               vmImage: 'ubuntu-latest'
             steps:
             - checkout: self
             - task: Bash@3
               name: InjectSecrets
               displayName: 'Inject credentials into liquibase.properties'
               inputs:
                 targetType: 'inline'
                 script: |
                   echo "Injecting credentials..."
                   sed -i "s|username=.*|username=${DB_USERNAME}|" liquibase.properties
                   sed -i "s|password=.*|password=${DB_PASSWORD}|" liquibase.properties
             - task: Bash@3
               displayName: 'Run Liquibase'
               inputs:
                 targetType: 'inline'
                 script: |
                   liquibase --defaultsFile=liquibase.properties update
      
    5. When you run the pipeline, Azure DevOps will prompt the user to enter the username and password.

    Hope this helps!

    Please Let me know if you have any queries.

    If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.

    0 comments No comments

  3. tarun k 280 Reputation points
    2025-06-17T08:20:27.73+00:00

    Hi Durga,

    But that liquibase property file is there in the repo not in yaml pipeline

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.