How to exclude tagged commit
I have a build pipeline in Azure Pipelines with
trigger:
branches:
include:
- '*'
tags:
include:
- v/*
In other words: I build all branches (in practice I only have one), and all tags that start with v/
(these are my releases).
When I push a commit and its tag, Azure Pipelines kicks off two builds - one for the branch and one for the tag - even though they're the same commit. This takes up unnecessary pipeline resources, particularly when I want to release from many repositories at the same time.
Is there a way to skip the "branch build" of a commit (or cancel if ongoing) when a "tag build" of the same commit is started?
do you know?
how many words do you know
See also questions close to this topic
-
Automate Azure Devops (FTP Upload) and Git to upload on Remote Server
The current setup is as below
- Version Control - Git
- Repos and Branch hosted on - Azure DevOps
- Codebase - External server
The dev team clones Azure Repo into local git project and any staged changes are committed via Git and pushed to specific branch of Azure DevOps. In this setup we would want to upload the changes to external FTP servers and avoid manual upload. Currently trying to use Azure Devops FTP Upload Task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/ftp-upload?view=azure-devops), however facing issues; yaml script as below
trigger: - main pool: vmImage: 'ubuntu-latest' variables: phpVersion: 7.4 webAppName: 'Test Project' buildConfiguration: 'Release' vmImageName: 'ubuntu-latest' steps: - publish: $(System.DefaultWorkingDirectory)/AzureRepoName artifact: Test Project Deploy - task: FtpUpload@2 displayName: 'FTP Upload' inputs: credentialsOption: inputs serverUrl: 'ftps://00.00.00.00:22' username: ftp-username password: ftp-password rootDirectory: '$(System.DefaultWorkingDirectory)/AzureRepoName' remoteDirectory: '/home/public_html' clean: false cleanContents: false preservePaths: true trustSSL: true
PROBLEM
Following errors occur when I commit (for test purposes) something.
Starting: PublishPipelineArtifact ============================================================================== Task : Publish Pipeline Artifacts Description : Publish (upload) a file or directory as a named artifact for the current run Version : 1.199.0 Author : Microsoft Corporation Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/publish-pipeline-artifact ============================================================================== Artifact name input: Test Project Deploy ##[error]Path does not exist: /home/vsts/work/1/s/AzureRepoName Finishing: PublishPipelineArtifact
I want to upload any staged change that is committed to main branch on Azure Devops to be automatically deploy on the remote FTP server
Thanks
-
Migrate Azure Devops Artifacts between organizations
I am trying to migrate (clone) an Azure Devops project to another project / organization. I successfully
- cloned the repos
- migrated the work items using Azure DevOps Migration Tools by NkdAgility
- I exported the build and release pipelines as json files and imported them again.
- I created a selfhosted agent on my VM and trying to run the build pipelines - the job "dotnet restore" on that.
- I created a new feed under Artifacts. Unfortunately the job with dotnet restore fails because it relies on the artifacts only available in the old project
How can I migrate the packages from the feeds of the old project to the new one(s)?
I assume I am supposed to clone the feeds of the old project somehow so that I can simply update the nuget.config with the name of the new organization. Thank you in advance.
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <!-- remove any machine-wide sources with <clear/> --> <clear /> <!-- also get packages from the NuGet Gallery --> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="DotNetArcade" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" /> <add key="<OLD_FEED1" value="https://pkgs.dev.azure.com/<old org>/_packaging/<OLD_FEED1>/nuget/v3/index.json" /> <add key="<OLD_FEED2" value="https://pkgs.dev.azure.com/<old org>/_packaging/<OLD_FEED2>/nuget/v3/index.json" /> <add key="<OLD_FEED3" value="https://pkgs.dev.azure.com/<old org>/_packaging/<OLD_FEED3>/nuget/v3/index.json" /> </packageSources> <activePackageSource> <add key="All" value="(Aggregate source)" /> </activePackageSource> </configuration>
-
Azure DevOps trigger at pipeline completion using different branch than expected
In the workflow of a pipeline triggering another pipeline according to this doc, I'm trying to set:
- feature-branch PR to develop-branch triggers stage-ci
- stage-ci runs, triggers stage-cd
- pipeline stage-cd runs
But in step 3, it gets the default branch, not the feature-branch. Does anyone know why this is happening? When the trigger in stace-ci is
trigger
(notpr
) it works finestage-ci.yaml:
trigger: none pr: branches: include: - develop
stage-cd.yaml
trigger: none pr: none resources: pipelines: - pipeline: stage-ci source: stage-ci trigger: true
-
Azure DevOps pipeline how set vcvars64.bat then call msbuild.exe from batch file?
On a local machine, I execute my build.bat after opening a x64 Native Tools Command Prompt for VS 2019, then build.bat calls msbuild.exe.
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat" build.bat
How can I do same in an Azure DevOps pipeline CmdLine task?
The build.bat call to msbuild.exe fails when called from azure-pipelines.yml CmdLine task.
Is there a reliable method to locate and call vcvars64.bat so that msbuild.exe can be found?
- task: CmdLine@2 displayName: 'build.bat calls msbuild' inputs: script: | build.bat
Azure pipeline error:
2022-05-06T15:42:53.3802703Z 'msbuild' is not recognized as an internal or external command, 2022-05-06T15:42:53.3803010Z operable program or batch file.
Thanks in advance for any tips or direction.
-
Azure Pipeline: Setting variable in one template, use it in expression in another
What I tried to achive:
- Set variable featureName in template 1 called
set-variable.yml
- Pass variable featureName as parameter to template 2 called
check-variable.yml
- Check if featureName parameter is empty in a compile time expression in template 2.
pipeline.yml:
trigger: - '*' # Run on all Branches pool: vmImage: ubuntu-latest stages: - stage: test1 jobs: - job: test1 steps: - template: set-variable.yml - template: check-variable.yml parameters: featureName: $(setVariables.featureName)
set-variable.yml:
steps: - script: | featureName='' echo "##vso[task.setvariable variable=featureName;isOutput=true]$featureName" displayName: Set variable name: setVariables
check-variable.yml:
parameters: - name: featureName type: string default: '' steps: - ${{ if ne(parameters.featureName, '') }}: - script: | echo "This should not be executed, but it is!" displayName: "featureName != ''"
The problem is, that the step
featureName != ''
incheck-variable.yml
gets executed, even though I set thefeatureName
variable in theset-variables.yml
template to be empty.(Passing of the variable
featureName
as a parameter to templatecheck-variable.yml
is working, see debugging attempts below)=== Debugging 1 ===
For debugging purpose, I've expanded the
check-variable.yml
with some debugging tasks.check-variable.yml:
parameters: - name: featureName type: string default: '' steps: - script: | echo "Check feature" echo "- featureNameDotted: [${{ parameters.featureName }}]" echo "- featureNameArray: [${{ parameters['featureName'] }}]" echo "- featureNameEnvDotted: [$featureNameEnvDotted]" echo "- featureNameEnvArray: [$featureNameEnvArray]" echo "- json: [${{ convertToJson(parameters.featureName) }}]" echo "- length: [${{ length(parameters.featureName) }}]" echo if [[ -z $featureNameEnvDotted ]]; then echo "featureNameEnvDotted is (empty or null)" else echo "featureNameEnvDotted not (empty or null)" fi echo if [[ $featureNameEnvDotted = '' ]]; then echo "featureNameEnvDotted = ''" else echo "featureNameEnvDotted != ''" fi echo if [[ $featureNameEnvDotted = 'hello' ]]; then echo "featureNameEnvDotted = 'hello'" else echo "featureNameEnvDotted != 'hello'" fi env: featureNameEnvDotted: ${{ parameters.featureName }} featureNameEnvArray: ${{ parameters['featureName'] }} displayName: "Debug: All" - ${{ if eq(parameters.featureName, '') }}: - script: | echo env: featureName: ${{ parameters.featureName }} displayName: "Debug: Empty!!" - ${{ if ne(parameters.featureName, '') }}: - script: | echo env: featureName: ${{ parameters.featureName }} displayName: "Debug: Not empty!!" - ${{ if eq(parameters.featureName, 'hello') }}: - script: | echo env: featureName: ${{ parameters.featureName }} displayName: "Debug: Equals 'hello'" - ${{ if ne(parameters.featureName, '') }}: - script: | echo "This should not be executed, but it is!" displayName: "featureName != ''"
The output of the task
Debug: All
is:Check feature
- featureNameDotted: []
- featureNameArray: []
- featureNameEnvDotted: []
- featureNameEnvArray: []
- json: []
- length: [27]
featureNameEnvDotted is (empty or null)
featureNameEnvDotted = ''
featureNameEnvDotted != 'hello'
The bash if's work all well. featureName is empty and it is not 'hello'. The 'length' one I don't understand.
And the following tasks get executed:
- Set variable
- Debug: All
- Debug: Not empty!!
- featureName != ''
Why do the tasks
Debug: Not empty!!
andfeatureName != ''
get executed, but taskDebug: Empty!!
not? featureName parameter IMO is empty!=== Debugging 2 ===
I've left
check-variable.yml
the same. But I setfeatureName
in theset-variable.yml
template to the value "hello". With this I wanted to check if the variablefeatureName
does get properly passed to the parameter of the templatecheck-variable.yml
set-variable.yml:
steps: - script: | featureName='hello' echo "##vso[task.setvariable variable=featureName;isOutput=true]$featureName" displayName: Set variable name: setVariables
The output of the task
Debug: All
is:Check feature
- featureNameDotted: [hello]
- featureNameArray: [hello]
- featureNameEnvDotted: [hello]
- featureNameEnvArray: [hello]
- json: [hello]
- length: [27]
featureNameEnvDotted not (empty or null)
featureNameEnvDotted != ''
featureNameEnvDotted = 'hello'
This again looks well. The parameter does hold the value 'hello' and the if's look good (still, length I don't understand).
And here the list of tasks which get executed:
- Set variable
- Debug: All
- Debug: Not empty!!
- featureName != ''
Why is
Debug: Equals 'hello'
not executed?parameters.featureName
holds something like the value 'hello', but it is not exactly the string 'hello'. Am I doing something wrong here? - Set variable featureName in template 1 called
-
Azure DevOps Publish Azure Function not working
I am trying to create a pipeline in order to publish my code in an Azure Function. In order to do that I am using the following as reference: https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-azure-devops?tabs=dotnet-core%2Cyaml%2Ccsharp
However I got the following error:Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
After struggling a little I got the following Build Pipeline yaml (I comment the code that cause the error):
trigger: - none pr: - none pool: vmImage: "windows-latest" variables: buildPlatform: 'Any CPU' buildConfiguration: 'Release' #output: "publish" #project: "*.csproj" solution: "**/*.sln" steps: - task: NuGetToolInstaller@1 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' #- task: DotNetCoreCLI@2 # inputs: # command: publish # arguments: "--configuration $(buildConfiguration) --output $(output)" # projects: $(project) # publishWebProjects: false # modifyOutputPath: false # zipAfterPublish: false - task: VSBuild@1 inputs: solution: '$(solution)' msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(Build.ArtifactStagingDirectory)"' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' - task: ArchiveFiles@2 displayName: "Zip Files" inputs: rootFolderOrFile: "$(Build.ArtifactStagingDirectory)" includeRootFolder: false archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip" - task: PublishBuildArtifacts@1 inputs: PathtoPublish: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip" artifactName: "drop"
which generates the following artifact:
that contains
and Release Pipeline:
steps: - task: AzureFunctionApp@1 displayName: 'Azure Function App Deploy' inputs: azureSubscription: '<SubscriptionName>' appType: functionApp appName: <FunctionApp Name> deploymentMethod: zipDeploy
the execution of the release pipeline ends as Successful
However nothing is published on Azure
Do you know what I am missing?