For a given project, I have four build pipelines, each pipeline Trigger has CI enabled, each has a branch filter for a single branch - master, Staging, QA, development. These work successfully, any completed pull request to one of those four branches are successfully kicking off a build process.
This morning, I created a new branch based off "development" branch. IT was a one-liner change, so I decided to make the change online in the browser using DevOps editor. I saved the change.
Immediately after saving the change online, I saw a new build pipeline was created (I had received an email saying my build failed). What caused the new Build pipeline to be created?
The new build pipeline looks to be auto-created, it is pure YAML:
pool:
vmImage: 'Ubuntu 16.04'
variables:
buildConfiguration: 'Release'
BuildPlatform: 'Any CPU'
Parameters.solution: = '*.sln'
Parameters.ArtifactName: = 'xxxxxx'
steps:
- task: NuGetToolInstaller#0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
- task: VSBuild#1
displayName: 'Build solution'
inputs:
solution: '$(Parameters.solution)'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PublishSymbols#2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
continueOnError: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
In the project, there were no pull requests created, and my private branch, I can see my change.
The email I received had this in the title (actual names removed):
[Build failed] MyProjectName CI - MyProjectName:MyBranchName - MyProejctName - bf9524f9
========
EDIT
I just found there is an azure-pipelines.yml file in the root folder of the branch. the contents match the above. Is this competing with the designer pipelines?
Yaml pipelines are better at scale, you can manage them in a central place, you can easily make mass edits and\or you can make them depend on each other to have more control. Visual designer is only good when you have couple of pipelines or you are only getting started with the whole pipelines thing.
Yaml pipelines do not necessary have to be in azure-pipelines.yml file. I store them in a separate repo :)
Updated comment:
Also the fact that there are no triggers added in your yaml mean that every new branch will queue builds. Read about 'trigger' on the yaml schema to get more understanding on this.
You can use something like below;
trigger:
branches:
include:
- master
- develop
exclude:
- no-build-branch
Given that there is none defined is behaves as below;
trigger:
branches:
include:
- '*'
These two are the same....
Designer picks the azure-pipelines.yml when you click edit. This is the default file name that gets picked up automatically to create a pipeline.
E.g. if you add the pipeline source to azure-pipelines.yml and commit/push it will automatically create a pipeline named 'Repo_Name CI' and queue a build as well.
Any new changes will work on it's merits as per the yaml definition.
you can always use different names and add as many pipelines you want as well.....
Related
I am trying to grab a schema from another artifact build and then build and push the artifact. The error I am getting no builds currently exist in the pipeline definition, I know that is usually from not having a pipeline run on that branch yet. I have run the pipeline and pushed the artifact to the repo on that branch so there is an image already there. The schema was published from the other build. I am not sure why it is not grabbing the artifact. Any help would be appreciated.
jobs:
- job: Build_Push_Artifact
steps:
- task: Docker#2
inputs:
containerRegistry: $(azureContainerRegistry)
command: "login"
- task: DownloadPipelineArtifact#2
inputs:
source: specific
project: $(projectId)
pipeline: $(schemaPublishPipelineId)
runVersion: latestFromBranch
runBranch: $(Build.SourceBranch)
artifact: $(schemaArtifact)
patterns: $(schemaArtifactPattern)
path: $(Build.SourcesDirectory)/src
A possible situation that I can reproduce on my side:
If the build pipeline runs failed in some steps, then even the artifact be published successfully, nothing will be catched.
And please try this simple structure:
trigger:
- none
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadPipelineArtifact#2
inputs:
buildType: 'specific'
project: '<Project Name>'
definition: '<Pipeline Name>'
buildVersionToDownload: 'latest'
targetPath: '$(Pipeline.Workspace)'
I just wanted to test how this is supposed to work. So the function in question is just the basic HTTP trigger template from visual studio and pushed to devops repo, the function app is manually made via portal, and I am using classic editor to make my pipelines
So I first build it
pool:
name: Azure Pipelines
steps:
- task: DotNetCoreCLI#2
displayName: 'Build project'
inputs:
projects: '**/*.csproj'
arguments: '--output publish_output --configuration Release'
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
includeRootFolder: false
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
and then use the artifact for the release pipeline
#Your build pipeline references an undefined variable named ‘Parameters.AzureSubscription’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.AppType’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.AppName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: AzureFunctionApp#1
displayName: 'Deploy Azure Function App'
inputs:
azureSubscription: '$(Parameters.AzureSubscription)'
appType: '$(Parameters.AppType)'
appName: '$(Parameters.AppName)'
package: '$(System.DefaultWorkingDirectory)/_testcase1-Azure Functions for .NET-CI/drop'
These are the generated YAML so yes I have the subscription, app type, and app name filled in. But anyway here's the classic editor if that say anything more.
To build artifact:
To release:
The thing is, both pipeline runs perfectly fine, they give green light claiming to be successful. It's just that I don't end up with a function in my function app. I have manually uploaded my function from visual studio, using a publishing profile, and then I run this pipeline, it effectively removes the function that I have manually published. I'm guessing there's something wrong with my artifact? That's why it's deploying absolutely nothing, and that's why it removes any existing functions on my app? What else might be the problem here?
I am trying to deploy my code from Azure to my local machine. The steps I followed:
Created deployment group
Run register script on my machine(the folders successfully created in C:\azagent)
Created pipeline.
For pipeline the generated YAML is:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: 'a31f9237-4431-41f2-b1a9-4370c7dc4828/a3a86133-79b3-437a-bc19-9665a420de4e'
- task: VSBuild#1
inputs:
solution: '**\*.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
restoreNugetPackages: true
- task: CopyFiles#2
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents: '**\bin\$(BuildConfiguration)\**'
TargetFolder: '$(build.artifactstagingdirectory)'
CleanTargetFolder: true
OverWrite: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
When I run the pipeline, it doesn't give any error but in release part I get an error:
The solution I am using has multiple projects. I need to deploy three projects on my machine. This is the first time I am using Azure DevOps and I don't have any clue about the error. Online articles are mostly explaining about cloud deployment and I could not find much about on-premise. In short my requirement is to deploy three projects from my repo on my local machine whenever I push any changes to master branch. Is there any step by step guide to achieve the same? What is the step I missed in the setup? Any help is much appreciated.
According to the description of the error message, first you need to check whether the corresponding build pipeline is selected as the release artifact source.
Then you can check whether the download artifacts path is consistent with the file path to the package(Package or Folder) of the IIS web app deploy task.
System.DefaultWorkingDirectory : The directory to which artifacts are downloaded during deployment of a release. The directory is cleared before every deployment if it requires artifacts to be downloaded to the agent. Same as Agent.ReleaseDirectory and System.ArtifactsDirectory.
Example: C:\agent\_work\r1\a
For details, please refer to predefined variables document.
my requirement is to deploy three projects from my repo on my local
machine whenever I push any changes to master branch.Is there any step by step guide to achieve the same?
To achieve this , in yaml build pipeline ,you need to set CI trigger: Continuous integration (CI) triggers cause a pipeline to run whenever you push an update to the specified branches.
In release pipeline , you need to set build pipeline as release artifact source, and then enable Continuous deployment trigger: This instructs Azure Pipelines to create new releases automatically when it detects new artifacts are available.
I seem to be missing something. When creating a build pipeline with the classic editor I can see an artifacts tab on the top right:
There I can browse what the compiler created, helping to find out the folder structure for the release pipeline.
Now when I create a build pipeline with the YAML template (also NET Framework) there is no such thing as Artifacts:
According to the logs, some files have been written. Is there some kind of browser for files, or do I have to guess which of these variables match to which folder in the logfiles?
This is how my summary page looks like:
This is the YAML:
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/Release.zip'
replaceExistingArchive: true
The YAML i use is mostly the standard YAML produced when building from a Github Repository. Does this affect if i can see Artifacts? Should i somehow copy the Github content to Azure first and then build it?
Update: i found the problem:
The default YAML file for GitHub Builds does NOT include a "publish" Step. After adding this to the end of the Build YAML
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
it in fact creates the "Artifacts" Tab:
Thanks for the help anyone
This seems be the different UI of classic and YAML.
To see the artifacts structure, you can go summary page(https://dev.azure.com/xxxx/xxxx/_build/results?buildId=xxx&view=results) of one build. Then focus one the right part and you will see like below:
Click on it, then you will see its folder structure(https://dev.azure.com/xxx/xxx/_build/results?buildId=xxx&view=artifacts&type=publishedArtifacts):
I'm pretty new on all AZURE devops.
I did just the minimal install on my VS solution, nuget Gitversiontask in my solution, push to Azure Git pipeline and it worked with the development branch.
I created ( GitFLOW) a feature named dostuff.
Made some changes on classes, then commit & push...
Version feature/my-app 6.1.0-dostuff0001came out ...Nuget pack and push... all fine.
Then did an another commit, pipeline start but at Nuget Push to artifacts ...ERROR 409 (Conflict - The feed already contains 'my-app 6.1.0-dostuff0001).
pipeline
- task: NuGetCommand#2
displayName: 'restore WinFormExtC.sln'
inputs:
restoreSolution: WinFormExtC/ActiveFramework.WinFormExtC.sln
feedsToUse: config
nugetConfigPath: NuGet/NuGet.Config
steps:
- task: VSBuild#1
displayName: 'Build solution WinFormExtC'
inputs:
solution: WinFormExtC/ActiveFramework.WinFormExtC.sln
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
steps:
- task: NuGetCommand#2
displayName: 'NuGet pack WinFormExtC'
inputs:
command: pack
packagesToPack: WinFormExtC/Package.nuspec
versioningScheme: byEnvVar
versionEnvVar: GitVersion.NuGetVersion
includeSymbols: true
Your build pipeline references an undefined variable named ‘Parameters.searchPatternPush’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: NuGetCommand#2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: '$(Parameters.searchPatternPush)'
publishVstsFeed: '505cb4b9-0633-4d83-b4b6-1e5fc7ad020f'
Question: How can I get the my-app 6.1.0-dostuff0001 increase or change when I queue the pipeline in Azure devops and the build task increment the version of feature branch?
Please remember that I'm new to all this Build, yml, config etc. concept.
Why is my version not incrementing?
GitVersion calculates the semantic version, this will only change once per release. Read more at
version increments
So, to make it incremental we can set and use a config file : GitVersion.yml. Below GitVersion.yml for your reference, it works for me when trigger from master branch.
mode: Mainline
tag-prefix: '[vV]'
commit-message-incrementing: MergeMessageOnly
branches:
feature:
regex: feature?[/-]
source-branches: ['develop']
release:
increment: Minor
regex: release?[/-]
develop:
is-mainline: true
increment: Patch
regex: develop$
master:
regex: master$
More GitVersion related info please reference the following blogs:
Azure DevOps pipelines with YAML and GitVersion
Effective Nuget Package Versioning in Azure DevOps with Git Tags and
GitVersion