Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure DevOps pipeline build locally with YAML

how can I simulate the build process of Azure Devops pipeline on the local machine before pushing it to branch to test the possible errors.

the solution gets build locally correct with no errors and warnings. also from the VS command line MSBuild builds the solution with no errors but on some push tries the pipeline build throws many errors mostly related to preprocessor defenition and precompiled header.

I wanted to know how can test the same process locally on my machine without pushing to repo.

azure-pipelines.yml
-------------------
pool:
  vmImage: 'vs2017-win2016'

steps:
- task: MSBuild@1
  displayName: 'Build solution'
  inputs:
    platform: 'Win32'
    configuration: 'release'
    solution: 'mysolution.sln'
- task: VSTest@2
  displayName: 'Run Test'
  inputs:
    platform: 'Win32'
    Configuration: 'release'
    testAssemblyVer2: |
     **\*.Test.dll
     !**\*TestAdapter.dll
     !**\obj\**
    runSettingsFile: project.Test/test.runsettings
    codeCoverageEnabled: true 
like image 839
Amir-Mousavi Avatar asked Nov 02 '18 14:11

Amir-Mousavi


People also ask

How do I run a YAML file locally?

To run and open . yml files you have to install Docker Compose. After the installation, go to your docker-compose. yml directory and then execute docker-compose up to create and start services in your docker-compose.

Can YAML be used to create a DevOps pipeline?

YAML makes it possible to code your configuration management by defining build and release pipelines in the YAML code.


1 Answers

If you are using a git repsotiory you can create another branch and make a pull request. As long as the pull request is not set to auto complete the code will not get committed to the repository.

If you are using a TFVC respository you can setup a gated build that is configured to fail. The pipeline should be a copy of your original pipeline but add a PowerShell task at the end of the build pipeline that throws a terminating error. Be sure to setup this gated build on a separate branch so it does not block normal development.

Write-Error "Fail here" -ErrorAction 'Stop'

You can now make pull requests or trigger a gated build without the code actually being commited.

You can use AzurePipelinesPS to install an agent on your local machine with the Install-APAgent command if you need another agent.

like image 97
Dejulia489 Avatar answered Sep 18 '22 23:09

Dejulia489