简体   繁体   中英

Azure DevOps - Clean up old releases on on-premise server?

I have a pipeline that deploys code to an IIS folder on an on-premise server. I'm trying to figure out how to best delete old release folders. I'm not seeing anything obvious within DevOps.

Is there a native way of doing this? Or should I roll my own PowerShell script to delete old releases?

Is there a native way of doing this?

Yes, of course there is.

Open your deploy task, go Advanced Deployment Options and then enable the option Remove Additional Files at Destination

在此处输入图片说明

Noted : This "delete" operation I mentioned is not mean that clear all the files in local IIS folder. It just delete the files at the destination where there's no corresponding file in the package which is being deployed.

In one word, for some files which same with previous, it will be override as the latest files. And, for any left over files from a previous deployment that are no longer required , they will be deleted .

If you do not trust this option and want to clear the previous files completely , you can also add the Powershell task before IIS manage task and run delete script.

Here is the sample script to delete local files:

Remove-Item -Path "D:\Websites2\*"

You can replace "D:\\Websites2\\*" as your local website file path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM