文章目錄
- 前言
- 一、新建代碼檢查
- 二、新建編譯構建
- 三、新建部署
- 三、新建流水線
前言
華為云流水線發布:自動檢查代碼,打包發布到服務器
一、新建代碼檢查
檢查代碼是否存在報錯
設置規則集
二、新建編譯構建
三、新建部署
模板選擇空模板或者自己去創建自定義模板
$directory = "${ProjectFile}"; if (-not (Test-Path -Path $directory)) { New-Item -Path $directory -ItemType Directory }
$siteName = "dev" # 替換成你的網站名稱$site = Get-Website -Name $siteNameif ($site.State -eq "Started") {C:\Windows\System32\inetsrv\appcmd.exe stop apppool /apppool.name:$siteName;Stop-Website -Name $siteName;Write-Host "The website $siteName has been stopped";
} else {Write-Host "The website $siteName is in an unknown state"
}
#上面截圖:同時發布的兩個站點,所以和下面的代碼是不一樣的,下面的去掉了一個站點
# 定義源文件路徑和目標文件夾路徑
$sourceFilePath = "${ProjectFile}/"
$destinationFolderPath = "D:/work/WebBackUp/service/${Project}/"# 獲取當前時間戳
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"# 構建目標文件路徑
$destinationFilePath = Join-Path -Path $destinationFolderPath -ChildPath "file_$timestamp"# 確保目標文件夾存在
if (-not (Test-Path -Path $destinationFolderPath)) {New-Item -ItemType Directory -Path $destinationFolderPath
}# 刪除目標文件夾中的所有文件和子文件夾
Remove-Item -Path (Join-Path -Path $destinationFolderPath -ChildPath "*") -Recurse -Force# 復制 $sourceFilePath 文件
Copy-Item -Path $sourceFilePath -Destination $destinationFilePath -Recurse -Force
刪除文件根據自己需要添加,不再一 一截圖了
#上面截圖:同時發布的兩個站點,所以和下面的代碼是不一樣的,下面的去掉了一個站點Copy-Item -Path D:/AppPackage/${Project}/${Time}/_PublishedWebsites/Web/* -Destination ${ProjectFile} -Recurse -Force
#上面截圖:同時發布的兩個站點,所以和下面的代碼是不一樣的,下面的去掉了一個站點
$siteName = "dev" # 替換成你的網站名稱$site = Get-Website -Name $siteNameif ($site.State -eq "Stopped") {C:\Windows\System32\inetsrv\appcmd.exe start apppool /apppool.name:$siteName;Start-Website -Name $siteName;Write-Host "The website $siteName is running";
} else {Write-Host "The website $siteName is in an unknown state"
}
三、新建流水線
模板選擇空模板