One of our customer is using the release pipelines with powershell code to deploy databricks notebooks ( dev-tst-uat-prd).
The way it is built is not really practical. So we have one workspace for multiple Business projects and therefore dedicated folders for each project in workspace ( project 1 projecct 2 project 3)
And current CICD pipeline will look into all of those folders and pick all the nested folders or files and will move them accross env.
Major problem here is this scenario:
Lets say code for project 1 and project 2 is approved, pushed and now code is in UAT env. But something happened and Business did not approve the project 2 to be pushed to production but project 1 needs to go to production. Here we have problem as if i trigger the piple all the code goes.
this is the code
$admin_dir = "/ADMIN/"
$data_dir = "/DATA/"
$data_project1 = "/Project 1/"
$data_project2 = "/Project 2/"
$data_project3 = "/Project 3/"
$nb_folders = @($admin_dir, $data_dir, $data_project1, $data_project3, $data_project3)
foreach ($nb_folder in $nb_folders) {
if ($target_ENV -eq 'd') {
Write-Host "The environment is dev, so we don't change resource names in notebooks"
}
else {
$nb_dir = $build_dir + $nb_folder
Write-Host "Changing variables in notebooks"
$files = gci -File -Path $nb_dir
foreach ($f in $files) {
Write-Output $f.name
for ($i = 0; $i -lt $replace_str.Count; $i++) {
(Get-Content $nb_dir$f).replace($replace_str[$i].Source, $replace_str[$i].Target) | Set-Content $nb_dir$f
}
}
if ($target_ENV -eq 'p') {
foreach ($f in $files) {
Write-Output $f.name
for ($i = 0; $i -lt $prd_replace_str.Count; $i++) {
(Get-Content $nb_dir$f).replace($prd_replace_str[$i].Source, $prd_replace_str[$i].Target) | Set-Content $nb_dir$f
}
}
}
}
if ($target_ENV -eq 'd') {
Write-Host "The environment is dev, so command for copying scripts from repo will be skipped"
}
else {
Import-DatabricksFolder -BearerToken $DatabricksToken -Region "westeurope" -LocalPath $nb_dir -DatabricksPath $nb_folder
}
}
#-------------------------------
# Cleanup
#-------------------------------
#Remove-Item $nb_dir*
Could there be a solution to this without making a duplicated CICD per project/path?
Is it possible if ($target_ENV -eq 'u')
env is UAT then user who is triggering the pipeline manually define the value of the $nb_folder
variable?