Publish-GitLabScheduledTasks
SYNOPSIS
Deploy scheduled tasks from a GitLab project to specified servers.
SYNTAX
Publish-GitLabScheduledTasks [[-Source] <String>] [[-ProjectName] <String>] [[-Deployto] <String[]>]
[[-TaskAuthor] <String>] [[-DestinationPath] <String>] [[-BranchName] <String[]>] [<CommonParameters>]
DESCRIPTION
This function automates the deployment of scheduled tasks from a GitLab project to specified servers. It validates the branch, copies project files to the destination servers, and registers or updates scheduled tasks based on the provided XML task definitions. The function also handles orphaned or stale tasks.
EXAMPLES
EXAMPLE 1
Deploys scheduled tasks from the GitLab project to Server1 and Server2, setting the task author to "John Doe".
EXAMPLE 2
Publish-GitLabScheduledTasks -Source "C:\GitLab\Project" -ProjectName "MyProject" -Deployto @('Server1') -BranchName @('main')
Deploys scheduled tasks from the specified source directory to Server1 for the "main" branch.
EXAMPLE 3
Deploys scheduled tasks from the current GitLab project directory to the servers specified in the `DEPLOYTO` environment variable.
PARAMETERS
-Source
The source directory containing the scheduled task files. Default is the `CI_PROJECT_DIR` environment variable.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: (Get-Item $Env:CI_PROJECT_DIR).FullName
Accept pipeline input: False
Accept wildcard characters: False
-ProjectName
The name of the GitLab project. Default is the `CI_PROJECT_NAME` environment variable.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: $Env:CI_PROJECT_NAME
Accept pipeline input: False
Accept wildcard characters: False
-Deployto
A list of servers to deploy the scheduled tasks to. Default is the `DEPLOYTO` environment variable, split by commas.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: $Env:DEPLOYTO -split ','
Accept pipeline input: False
Accept wildcard characters: False
-TaskAuthor
The author of the scheduled tasks. This value is used to set the `Author` field in the task registration.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-DestinationPath
The destination path on the target servers where the project files will be copied. Default is `L:\Scripts_ScheduledTasks`.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: L:\Scripts\_ScheduledTasks
Accept pipeline input: False
Accept wildcard characters: False
-BranchName
A list of branch names for which the deployment should occur. Default is `@('master', 'main')`.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: @('master', 'main')
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.