'line 47, in schemachange raise ValueError("Invalid root folder: %s" % rootfolder) ValueError: Invalid root folder: /home/vsts/work/1/s/migrations
This is my Yaml code
# Deploy database changes using snowchange
# https://github.com/Snowflake-Labs/snowchange
# (see https://aka.ms/yaml for the YAML schema reference)
trigger:
branches:
include:
- main
paths:
include:
- /migrations
pool:
vmImage: 'ubuntu-latest'
variables:
- group: demo-variables
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.8.x'
inputs:
versionSpec: '3.8.x'
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo 'Starting bash task'
echo "PROJECT_FOLDER $(PROJECT_FOLDER)"
python --version
echo 'Step 1: Installing schemachange'
pip install schemachange --upgrade
echo 'Step 2: Running schemachange'
schemachange -f $(PROJECT_FOLDER)/migrations -a $(SF_ACCOUNT) -u $(SF_USERNAME) -r $(SF_ROLE) -w $(SF_WAREHOUSE) -d $(SF_DATABASE) -c $(SF_DATABASE).SCHEMACHANGE.CHANGE_HISTORY --create-change-history-table
env:
SNOWFLAKE_PASSWORD: $(SF_PASSWORD)
After this run- getting below output result:
File "/opt/hostedtoolcache/Python/3.8.11/x64/lib/python3.8/site-packages/schemachange/cli.py", line 47, in schemachange raise ValueError("Invalid root folder: %s" % root_folder) ValueError: Invalid root folder: /home/vsts/work/1/s/migrations ##[error]Bash exited with code '1'. Finishing: Bash
Solution 1:[1]
Replace this $(Build.SourceDirectory) where you have ProjectFolder/migration or the name of your own folder path, and remove the x behind Python and use Python 3.8 or lower.
Solution 2:[2]
For the above yml code if the migrations folder and azure_pipeline.yml file reside in same branch then (PROJECT_FOLDER) value which is set to $(System.DefaultWorkingDirectory) in demo-variables will work. If your migrations folder and azure_pipeline.yml file reside in different locations then Option 1: PROJECT_FOLDER value has to be set to the correct path so that your schemachange command could recognize the root folder i.e.., migrations. Option 2:Include a checkout step and checkout to the migrations folder branch(Ex:- checkout: git://SampleProject@Dev_Branch) then (PROJECT_FOLDER) value which is set to $(System.DefaultWorkingDirectory) will work in this case.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeremy Caney |
| Solution 2 | Sridevi Jaddu |
