Skip to content

Commit

Permalink
Merge branch 'convertto-triggers' into 1.60
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-peterson committed Apr 26, 2022
2 parents 6e4244b + 050a79b commit 5ad5f9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/GitlabCli/GitlabCli.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

# Projects
'Get-GitlabProject'
'Get-GitlabProjectAsTriggerPipeline'
'ConvertTo-Triggers'
'New-GitlabProject'
'Update-GitlabProject'
'Move-GitlabProject'
Expand Down
19 changes: 15 additions & 4 deletions src/GitlabCli/Projects.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,15 @@ function Get-GitlabProject {
Get-FilteredObject $Select
}

function Get-GitlabProjectAsTriggerPipeline {
function ConvertTo-Triggers {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
$InputObject
$InputObject,

[Parameter(Mandatory=$false)]
[ValidateSet('', 'depend')]
[string]
$Strategy = 'depend'
)
Begin {
$Yaml = @"
Expand All @@ -192,14 +197,20 @@ stages:
continue
}
$Projects += $Object.ProjectId
$Yaml += "`n`n"
$Yaml += @"
$($Object.Name):
stage: trigger
trigger:
project: $($Object.PathWithNamespace)
strategy: depend
"@
if ($Strategy) {
$Yaml += @"
strategy: $Strategy
"@
}
}
}
End {
Expand Down

0 comments on commit 5ad5f9e

Please sign in to comment.