maikvandergaag / msft-extensions

Repository for extensions mainly used for Azure DevOps Extensions
https://msftplayground.com
MIT License
126 stars 80 forks source link

Delete items from the workspace that are not in the repository #540

Closed vinayprakash893 closed 2 months ago

vinayprakash893 commented 3 months ago

In repo, im deleting the few files eg: out of 4 pbix files, i have deleted 2 files in repo , so those two should be removed from PowerBI workspace as well.

im using the below script to get the diff which files got deleted Write-Host "Source file '$sourceFile' does not exist. Marked for deletion..." $destsubfolder = Split-Path $sourceFile $deletedFolderPath = Join-Path $deletedfolder $destsubfolder $dummyFileName = Split-Path $sourceFile -Leaf $dummyFilePath = Join-Path $deletedFolderPath $dummyFileName if (-not (Test-Path -Path $deletedFolderPath)) { $null = New-Item -ItemType Directory -Path $deletedFolderPath } $null = New-Item -ItemType File -Path $dummyFilePath }

but if i want to send these in the azure devops pipline, i cannot hardcode thevalues in the repot names, how do i pass dynamically with array or loop..?

task: maikvandergaag.maikvandergaag-power-bi-actions.PowerBIActions.PowerBIActions@5 displayName: 'Power BI Action: DeleteReport' condition: eq(variables['Demo_deleted'], True) inputs: PowerBIServiceEndpoint: 'powerbi-actions' Action: DeleteReport WorkspaceName: 'Demo-workspace' ReportName: 'Demofile-1'

reference : https://github.com/maikvandergaag/msft-extensions/issues/245

maikvandergaag commented 3 months ago

You could do this by adding a PowerShell task to your Pipeline that retrieves the values from PowerBi. These values can then be passed as a variable to the next task

vinayprakash893 commented 3 months ago

Yes, i have tried using the powershell script which will provide the list of files deleted in ARRAY,

But do i pass this to the below task..?

maikvandergaag commented 3 months ago

It is possible to start multiple tasks based on a dynamic variable. You should look into that.

vinayprakash893 commented 3 months ago

Sure, I will look for a solution, if i find anything useful, i will update in the comments, so that it may be useful for others,

Thank you for building the wonderful APP.

maikvandergaag commented 3 months ago

Great, this it succeed. Is is ok for me to close the issue?

vinayprakash893 commented 2 months ago

Thank you, yes this can be closed.