Skip to content

This module contains Sampler project build tasks for Azure DevOps Services and Azure DevOps Server.

License

Notifications You must be signed in to change notification settings

SynEdgy/Sampler.AzureDevOpsTasks

Repository files navigation

Sampler.AzureDevOpsTasks

This module contains Sampler project build tasks for Azure DevOps Services and Azure DevOps Server.

Build Status Azure DevOps coverage (branch) codecov Azure DevOps tests PowerShell Gallery (with prereleases) PowerShell Gallery

Code of Conduct

This project has adopted this Code of Conduct.

Releases

For each merge to the branch main a preview release will be deployed to PowerShell Gallery. Periodically a release version tag will be pushed which will deploy a full release to PowerShell Gallery.

Contributing

Please check out common DSC Community contributing guidelines.

Change log

A full list of changes in each version can be found in the change log.

Commands

Refer to the comment-based help for more information about these helper functions.

Invoke-AzureDevOpsTasksGit

This command executes git with the provided arguments and throws an error if the call failed.

Syntax

Invoke-AzureDevOpsTasksGit [-Argument] <string[]> [<CommonParameters>]

Outputs

[System.String]

Example

Invoke-AzureDevOpsTasksGit -Argument @('config', 'user.name', 'MyName')

Calls git to set user name in the git config.

Tasks

These are Invoke-Build tasks. The build tasks are primarily meant to be run by the project Sampler's build.ps1 which wraps Invoke-Build and has the configuration file (build.yaml) to control its behavior.

To make the tasks available for the cmdlet Invoke-Build in a repository that is based on the Sampler project, add this module to the file RequiredModules.psd1 and then in the file build.yaml add the following:

ModuleBuildTasks:
  Sampler.AzureDevOpsTasks:
    - 'Task.*'

Create_AzureDevOps_Release

Meta task that runs tasks to create a tag if necessary, and pushes updated changelog to a branch, then create a PR based on the pushed branch.

The following tasks are run (in order):

  • Create_Release_Git_Tag (from module Sampler)
  • Create_Changelog_Branch (from module Sampler)
  • Create_PR_From_SourceBranch

Please see each individual task for documentation.

This is an example of how to use the task in the azure-pipelines.yml file:

- task: PowerShell@2
  name: createAzureDevOpsRelease
  displayName: 'Create Azure DevOps Release'
  inputs:
    filePath: './build.ps1'
    arguments: '-tasks Create_AzureDevOps_Release'
    pwsh: true
  env:
    MainGitBranch: 'main'
    BasicAuthPAT: $(BASICAUTHPAT)

This is an example of how to use the task in the build.yaml file:

  publish:
    - Create_AzureDevOps_Release

Make sure to pass required environment variables when the task publish runs.

Create_PR_From_SourceBranch

This build task creates a pull request based on an already pushed branch.

This task requires that (the Sampler) task Create_Changelog_Branch have been ran, or by any other means that created a branch with the correct name.

This is an example of how to use the task in the azure-pipelines.yml file:

- task: PowerShell@2
  name: sendChangelogPR
  displayName: 'Send Changelog PR'
  inputs:
    filePath: './build.ps1'
    arguments: '-tasks Create_PR_From_SourceBranch'
    pwsh: true
  env:
    MainGitBranch: 'main'
    BasicAuthPAT: $(BASICAUTHPAT)

This is an example of how to use the task in the build.yaml file:

  publish:
    - Create_PR_From_SourceBranch

Make sure to pass required environment variables when the task publish runs.

Task parameters

Some task parameters are vital for the resource to work. See comment based help for the description for each available parameter. Below is the most important.

Task configuration

The build configuration (build.yaml) can be used to control the behavior of the build task.

####################################################
#            Pull Request Configuration            #
####################################################
PullRequestConfig:
  BranchName: 'updateChangelogAfterv{0}'
  Title: 'Updating Changelog since release of v{0} +semver:skip'
  Description: 'Updating Changelog since release of v{0} +semver:skip'
  Instance: 'azdoserver.company.local'
  Collection: 'MyCollection'
  Project: 'MyProject'
  RepositoryID: 'MyRepositoryName'
  Debug: false

Section PullRequestConfig

See the Azure DevOps Server Rest API documentation for more information what values to use for each property.

If the property RepositoryID is not set, the task will default to the project name found by Sampler pipeline, which is normally the module name. Please note that the property Project above and the project name are two different properties.

The property Debug when set to true will output the response from the Rest API call.

The property BranchName can be used to override the default branch name that is used as the source branch for the pull request. The branch name can contain a {0} placeholder which will be replaced with the module version.

The property Title and Description can be used to override the default title and description that is used for the pull request. Both values can contain a {0} placeholder which will be replaced with the module version.

About

This module contains Sampler project build tasks for Azure DevOps Services and Azure DevOps Server.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published