Giter VIP home page Giter VIP logo

azure-pipelines's Introduction

Job and Step Templates for Azure Build Pipelines

NOTE: These may be a little stale, because I'm not using them myself right now...

Usage

First configure a github service connection

You can use your existing endpoint connection, or add a new one. If you add a new one, consider using a generic name like "github" so forks can configure it the same way.

You can find this in your Project Settings under the Pipeline Service connections (i.e. https://dev.azure.com///_settings/adminservices) in Azure Devops. NOTE: Project settings is the gear in the bottom left corner of the UI as of April 2019!

In this example, I'm using the endpoint name github

Add this to the beginning of your azure-pipelines.yml

resources:
  repositories:
    - repository: poshcode
      type: github
      endpoint: github
      name: PoshCode/Azure-Pipelines
      ref: refs/tags/1.0.0

This will make the templates in this repository available in the poshcode namespace, so you can run use our GitVersion-job to version your builds by referencing the template GitVersion-job.yml@poshcode following these steps:

  1. Copy our GitVersion.yml into the root of your project. You can modify it, but be aware that as of GitVersion 4.0.0 there's a bug in the "Mainline" mode which requires you to manually specify the "increment" setting for each branch.

  2. Use the GitVersion version number in your build name. I use the InformationalVersion (which is the most verbose string), you could use SemVer instead...

name: $(Build.DefinitionName)_$(GitVersion_InformationalVersion)
  1. Call the template as the first job in your azure-pipelines:
jobs:
  - template: GitVersion-job.yml@poshcode
  1. Use the GitVersion.outputs in your build job by creating and using a variable:
  - job: Build
    dependsOn: GitVersion
    variables:
      SemVer: $[dependencies.GitVersion.outputs['GitVersion.SemVer']]
    steps:
    - powershell: Build-Module -SemVer $(SemVer) -Verbose
      displayName: 'Build-Module'

See the Azure docs for Templates and the YAML schema for more details.

azure-pipelines's People

Contributors

fishmanpet avatar jaykul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

azure-pipelines's Issues

Custom PSScriptAnalyzer rules not failing properly

When PSScriptAnalyzer reports failures for custom rules, it doesn't the rulename doesn't just include the rule name, but the source as well. As an example, I have a custom rule I got from Get-ScriptAnalyzerRule:

RuleName         : Measure-UnicodeSubstitutions
CommonName       : Measure-UnicodeSubstitutions
Description      : When copying code from the internet, sometimes quotes and hyphens are replaced with unicode characters
                   To fix this, replace the characters with "standard" characters
SourceType       : Module
SourceName       : CustomPSSARules
Severity         : Warning
ImplementingType : Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.ExternalRule

The RuleName is simply Measure-UnicodeSubstitutions. However, in the results it looks like this:

RuleName                            Severity     ScriptName Line  Message                                                     
--------                            --------     ---------- ----  -------                                                     
CustomPSSARules\Measure-UnicodeSubs Error        UMN-module.p 256   Bad unicode characters                                      
titutions                                        sm1                                                                          

In the results, the rulename is Source\Rulename (in this case my rules from a module named CustomPSSARules. Because the rule names are in different formats, the code to match results with all the rules fails:

if ($Failures = $ScriptAnalyzer.Results.Where( {$_.RuleName -EQ "$Rule"})) {

In my case $_.RuleName is CustomPSSARules\Measure-UnicodeSubstitutions but $Rule from the list of previously generated Rules is Measure-UnicodeSubstitutions and they aren't equal.

I changed the line to do a like comparison instead:
if ($Failures = $ScriptAnalyzer.Results.Where( {$_.RuleName -like "*$Rule"})) {
And that properly fails the line. I'll make a PR for this shortly.

GitVersion step will fail when versoin @5 is installed

Currently v5 is the latest version of the GitVersion Task extension in AzDo
Afiak, you can't install older versions via the marketplace (if possible, please let me know)
so any templates referencing to the gitversion-step.yml will fail

Code Coverage Report doesn't include line highlighting

The "default" code coverage directory you've picked (D:\a\1\a) doesn't work because ReportGenerator needs to know exactly what directory the files are in, not just the directory that contains the directory that files are in.

I did some testing by hand with report generator, and using the equivalent of D:\a\1\a results in File module.psm1 does not exist (any more).. However if I specify the path with the version number, so like D:a\1\a\1.0.0 it is able to find the module file. I'm going to dig into this a bit more as I wrap my head around how all the variables are defined but If the code coverage directory is set to something like $ArtifiactDownloadDirectory\$semver it should work. Just a matter of figuring out what variable that $semver is in that stage of the pipeline

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.