Skip to content

Ping the PowerShell Version to 7.2.11 in codegen pipeline #24215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions .azure-pipelines/code-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,25 @@ jobs:
}
git checkout src/${{ parameters.ServiceName }};
git checkout -b codegen/${{ parameters.ServiceName }} origin/${{ parameters.TargetBranch }};
- pwsh: |
#Uninstall-Module -Name PackageManagement -AllVersions
Install-Module -Name PowerShellGet -RequiredVersion 2.2.3 -Force;
Install-Module -Name platyPS -RequiredVersion 0.14.2 -Force;
Install-Module -Name Az.Accounts -Force;
Import-Module .\tools\Gen2Master\MoveFromGeneration2Master.ps1;
Move-Generation2Master -SourcePath .\artifacts\src\${{ parameters.ServiceName }} -DestPath .\src\${{ parameters.ServiceName }};
git config user.email "65331932+azure-powershell-bot@users.noreply.github.com";
git config user.name "azure-powershell-bot";
git add ./src;
git add tools/CreateMappings_rules.json;
git commit -m "Move ${{ parameters.ServiceName }} to ${{ parameters.TargetBranch }}";
git remote set-url origin https://azure-powershell-bot:$(GithubToken)@github.com/Azure/azure-powershell.git;
git push origin codegen/${{ parameters.ServiceName }} --force;
displayName: Create codegen/${{ parameters.ServiceName }} branch
- task: PowerShell@2
displayName: 'Create codegen/${{ parameters.ServiceName }} branch'
inputs:
targetType: 'inline'
script: |
#Uninstall-Module -Name PackageManagement -AllVersions;
Install-Module -Name PowerShellGet -RequiredVersion 2.2.3 -Force;
Install-Module -Name platyPS -RequiredVersion 0.14.2 -Force;
Install-Module -Name Az.Accounts -Force;
Import-Module .\tools\Gen2Master\MoveFromGeneration2Master.ps1;
Move-Generation2Master -SourcePath .\artifacts\src\${{ parameters.ServiceName }} -DestPath .\src\${{ parameters.ServiceName }};
git config user.email "65331932+azure-powershell-bot@users.noreply.github.com";
git config user.name "azure-powershell-bot";
git add src;
git add tools/CreateMappings_rules.json;
git commit -m "Move ${{ parameters.ServiceName }} to ${{ parameters.TargetBranch }}";
git remote set-url origin https://azure-powershell-bot:$(GithubToken)@github.com/Azure/azure-powershell.git;
git push origin codegen/${{ parameters.ServiceName }} --force;
arguments: '-RequiredPsVersion $(PSVersion)'
- pwsh: |
$SourceBranch = "$(Build.SourceBranch)"
$SourceBranch = $SourceBranch.Replace("refs/heads/", "")
Expand All @@ -101,4 +105,4 @@ jobs:
$(git log -1 origin/$SourceBranch -- ./src/${{ parameters.ServiceName }})
"
./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(GithubToken) -Description $Description
displayName: Create PR to main branch
displayName: Create PR to main branch
10 changes: 8 additions & 2 deletions tools/Gen2Master/MoveFromGeneration2Master.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ Function Move-Generation2Master {

process {
#Region Handle the module whoes folder is a subfolder of the module folder.
$ModuleName = $SourcePath.Replace('/', '\').Split('\src\')[1].Split('\')[0]
if (-not (Test-Path -Path $SourcePath)) {
Write-Error "The source path $SourcePath does not exist." -ForegroundColor Red
return
}
$SourceFolder = Get-Item -Path $SourcePath
$ModuleName = $SourceFolder.Name

$DestParentPath = $DestPath
While ("" -ne $DestParentPath) {
Expand All @@ -43,6 +48,7 @@ Function Move-Generation2Master {
New-Item "$DestPath\$ModuleName\help" -ItemType Directory
Update-MappingJson $ModuleName
}
$DestPath = (Get-Item -Path $DestPath).FullName
$Dir2Copy = @{
'custom' = 'custom'
'examples' = 'examples'
Expand All @@ -68,7 +74,7 @@ Function Move-Generation2Master {
$Psd1Metadata = Import-LocalizedData -BaseDirectory "$PSScriptRoot/Templates" -FileName "Module.psd1"
}
foreach ($submoduleDir in $submoduleDirs) {
$psd1File = Get-ChildItem -Filter *.psd1 -File -Path $submoduleDir
$psd1File = Get-ChildItem -Filter *.psd1 -File -Path $submoduleDir.FullName
write-host ("psd1 file name {0}" -f $psd1File.Name)
$submoduleName = $psd1File.Name.Split('.')[-2]
Foreach ($Dir in $Dir2Copy.GetEnumerator()) {
Expand Down