Azure DevOps Pipeline not update correct the website - azure-devops

i build a pipeline, that should run on changes on master-branch. at the moment, it runs right, but the code is not changed. If i delete and recreate the pipeline, the update is correct installed. Where is my Error? The server is actually a F1 Plan from Azure (a linux maschine).
parameters:
- name: artifactName
type: string
default: drop
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
displayName: 'Use NuGet 5.11.0'
inputs:
versionSpec: 5.11.0
checkLatest: true
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: false
projects: '**/*.csproj'
arguments: '-r linux-x64 --output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: '...nameOfSubscription'
appType: 'webAppLinux'
WebAppName: '...nameOfWebApp'
packageForLinux: '$(build.artifactstagingdirectory)/*.zip'
RuntimeStack: 'DOTNETCORE|5.0'

You simply didn't deploy application to Azure. What you did is create a package for deployment.
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
It publishes artifact, but it doesn't publish your app to Azure.
Please take a look on documentation here
If you want to do this in the same job it would be like:
- task: AzureWebApp#1
inputs:
azureSubscription: '<Azure service connection>'
appType: 'webAppLinux'
appName: '<Name of web app>'
package: '$(build.artifactstagingdirectory)/*.zip'
Please remeber to provide all needed details.

Related

Error Testing DotNet Project on Azure Devops

I'm trying to setup a build on azure devops to suppress flaky tests and continue going through the the tasks, but the test section that I got from the documentation fails regardless of what I try and do
I setup my test section based off of this document
https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops&tabs=dotnetfive
specifically lifting this block
steps:
# ...
# do this after your tests have run
- script: dotnet test <test-project> --logger trx
- task: PublishTestResults#2
condition: succeededOrFailed()
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'
I get this error message
##[error]Bash exited with code '1'.
and my azure pipeline looks like this
parameters:
- name: solution
type: string
- name: buildPlatform
type: string
- name: buildConfiguration
type: string
steps:
- task: UseDotNet#2
inputs:
version: '5.0.x'
packageType: 'sdk'
- task: DotNetCoreCLI#2
displayName: 'dotnet restore'
inputs:
command: restore
projects: ${{ parameters.solution }}
feedsToUse: select
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: build
includeNuGetOrg: true
projects: ${{ parameters.solution }}
arguments: '--configuration ${{ parameters.buildConfiguration }}'
- script: dotnet test ${{ parameters.solution }} --logger trx
- task: PublishTestResults#2
condition: succeededOrFailed()
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'
- task: CopyFiles#2
displayName: 'copy build'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*
!.git/**/*
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
displayName: 'publish artifact'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop
- task: ArchiveFiles#2
displayName: 'zip nuget packages'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/_nupkgs'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/NugetPackages.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
displayName: 'publish nuget packages'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/NugetPackages.zip'
artifactName: nugetPackages

Azure DevOps CI/CD pipeline No package found error

I have a Azure DevOps CI/CD pipeline:
trigger:
- master
pool:
vmImage: ubuntu-latest
variables:
buildConfiguration: 'Release'
stages:
- stage: Build
jobs:
- job: Build
displayName: 'Build'
steps:
- task: DotNetCoreCLI#2
inputs:
command: 'build'
configuration: 'Release'
projects: |
$(System.DefaultWorkingDirectory)/src/*.csproj
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration $(buildConfiguration)
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Test
dependsOn: Build
condition: succeeded()
jobs:
- job: Deploy
displayName: 'Deploy to Test'
steps:
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'xxx'
appType: 'webApp'
WebAppName: 'xxx'
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
When I run it I get
Error: No package found with specified pattern: /home/vsts/work/1/drop/13325.zip<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
The build stage produces an artifact, and it is in the 'drop' directory, so I can not wrap my mind around it why publish task can not find it?
As #Daniel indicated you will also need a download artifacts task inside your Test stage as the different stages keep separate working directories.
- stage: Test
dependsOn: Build
condition: succeeded()
jobs:
- job: Deploy
displayName: 'Deploy to Test'
steps:
- task: DownloadBuildArtifacts#1
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'xxx'
appType: 'webApp'
WebAppName: 'xxx'
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

Azure DevOps Pipeline forever stuck in Pending

We've got an Azure DevOps Pipeline running on a self-hosted against without parallelism that is not running it's Deployment Job or Step.
The version I'm posting below will have two stages, but note that I have tried this by removing the second stage and converting the entire stage to a job, and still the same result. I should also note that I've got multiple pipelines with multiple jobs that run just fine, it seems to be an issue with the specific deployment job.
The second stage is forever stuck in Pending ("Job is Pending"). It will never proceed to start running.
The stage can also not be cancelled, and per the image above, it's been stuck for 2 months.
I should also note that I have submitted this to the Azure Developer Community at developercommunity.visualstudio.com, but I think they've abandoned my ticket.
I'm sure that there are many successful CI/CD deployments in Azure DevOps, I just can't tell what I'm doing wrong here. I am utilizing a working method in our separate Release Pipelines that we are running manually.
Below is the affected pipeline, any guidance would be greatly appreciated.
trigger: none
variables:
ArtifactPackageName: 'app.zip'
DeploySite.IISDeploymentType: 'IISWebsite'
DeploySite.ActionIISWebsite: 'CreateOrUpdateWebsite'
DeploySite.WebsiteName: 'REDACTED'
DeploySite.WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\REDACTED'
DeploySite.AddBinding: false
DeploySite.VirtualPathForApplication: '/REDACTED'
DeploySite.AppPoolName: 'REDACTED'
DeploySite.VirtualApplication: 'REDACTED'
DeploySite.Package: $(Pipeline.Workspace)/drop/$(ArtifactPackageName)
DeploySite.RemoveAdditionalFilesFlag: true
DeploySite.TakeAppOfflineFlag: true
DeploySite.XmlTransformation: false
DeploySite.XmlVariableSubstitution: true
DeploySite.SetParametersFile: $(Pipeline.Workspace)/drop/REDACTED.SetParameters.xml
DeploySite.JSONSettingsFiles: '**/appsettings.json'
stages:
- stage: 'Build'
displayName: 'Build'
jobs:
- job: 'Build'
displayName: 'Build'
pool:
name: REDACTED
variables:
Solution: '**/*.sln'
BuildPlatform: 'Any CPU'
BuildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
displayName: 'Install NuGet Tools'
- task: NuGetCommand#2
displayName: 'Restore NuGet Packages'
inputs:
restoreSolution: '$(Solution)'
- task: VSBuild#1
displayName: 'MSBuild'
inputs:
solution: '$(Solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(Build.ArtifactStagingDirectory)\$(ArtifactPackageName)"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PublishBuildArtifacts#1
displayName: 'Publish Build Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: drop
publishLocation: 'Container'
- stage: 'Deploy'
displayName: 'Deploy'
dependsOn: 'Build'
jobs:
- deployment: 'Deploy'
displayName: 'Deploy'
continueOnError: false
timeoutInMinutes: 10
workspace:
clean: all
pool:
name: REDACTED
environment:
name: SERVER-DEV
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- download: current
displayName: 'Download Artifact'
artifact: drop
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'Stop IIS App Pool'
continueOnError: false
inputs:
IISDeploymentType: IISApplicationPool
ActionIISApplicationPool: StopAppPool
StartStopRecycleAppPoolName: '$(Parameters.WebsiteName)'
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
continueOnError: false
inputs:
WebSiteName: '$(DeploySite.WebsiteName)'
VirtualApplication: '$(DeploySite.VirtualApplication)'
Package: '$(DeploySite.Package)'
RemoveAdditionalFilesFlag: $(DeploySite.RemoveAdditionalFilesFlag)
SetParametersFile: $(DeploySite.SetParametersFile)
TakeAppOfflineFlag: $(DeploySite.TakeAppOfflineFlag)
XmlTransformation: $(DeploySite.XmlTransformation)
XmlVariableSubstitution: $(DeploySite.XmlVariableSubstitution)
JSONFiles: $(DeploySite.JSONSettingsFiles)
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'Start IIS App Pool'
continueOnError: true
inputs:
IISDeploymentType: IISApplicationPool
ActionIISApplicationPool: StartAppPool
StartStopRecycleAppPoolName: '$(Parameters.WebsiteName)'
I had the same error.
I renamed - deployment: Deploy to - deployment: Deployment
...and it started to work.
Changed
from - deployment: Deploy To - deployment: Deployment
I was facing the same error on a stage with only a Deployment job.
A successful workaround is to replace the Deployment job with a regular Job. However, this approach won't keep your deployment history or allow a deployment strategy.
In your case, the Deploy would be:
- stage: 'Deploy'
displayName: 'Deploy'
dependsOn: 'Build'
jobs:
- job: 'Deploy'
displayName: 'Deploy'
continueOnError: false
timeoutInMinutes: 10
workspace:
clean: all
pool:
name: REDACTED
steps:
- download: current
displayName: 'Download Artifact'
artifact: drop
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'Stop IIS App Pool'
continueOnError: false
inputs:
IISDeploymentType: IISApplicationPool
ActionIISApplicationPool: StopAppPool
StartStopRecycleAppPoolName: '$(Parameters.WebsiteName)'
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
continueOnError: false
inputs:
WebSiteName: '$(DeploySite.WebsiteName)'
VirtualApplication: '$(DeploySite.VirtualApplication)'
Package: '$(DeploySite.Package)'
RemoveAdditionalFilesFlag: $(DeploySite.RemoveAdditionalFilesFlag)
SetParametersFile: $(DeploySite.SetParametersFile)
TakeAppOfflineFlag: $(DeploySite.TakeAppOfflineFlag)
XmlTransformation: $(DeploySite.XmlTransformation)
XmlVariableSubstitution: $(DeploySite.XmlVariableSubstitution)
JSONFiles: $(DeploySite.JSONSettingsFiles)
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'Start IIS App Pool'
continueOnError: true
inputs:
IISDeploymentType: IISApplicationPool
ActionIISApplicationPool: StartAppPool
StartStopRecycleAppPoolName: '$(Parameters.WebsiteName)'

My build pipeline in Azure DevOps running twice for each push

I tried to build a CI/CD pipeline for my project on Azure DevOps. I was successful for sometime but now i can find that my dev branch's code push is initiating the build pipeline for two times, one in master pipeline and one in dev pipeline and i am also having two releases in my app center. I tries checking triggers and all on my trigers page in Azure DevOps but that wasn't any helpful. Can anyone out there help me out in this. Thank you.
The following is my YAML configuration file:
For Master
trigger:
- master
pool:
vmImage: 'macos-latest'
steps:
- task: Gradle#2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
tasks: 'assembleRelease'
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.apk'
apksignerKeystoreFile: 'key store file'
apksignerKeystorePassword: '$(keyPassword)'
apksignerKeystoreAlias: 'alias'
apksignerKeyPassword: '$(keyPassword)'
- task: CopyFiles#2
inputs:
SourceFolder: '$(Agent.BuildDirectory)'
Contents: '**/*.apk'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'artifact'
publishLocation: 'Container'
- task: AppCenterDistribute#3
inputs:
serverEndpoint: 'VSAC'
appSlug: 'app slug'
appFile: '**/*.apk'
symbolsOption: 'Android'
releaseNotesOption: 'input'
releaseNotesInput: 'CICD Release Build'
destinationType: 'groups'
distributionGroupId: 'dist group id'
For Dev
trigger:
- dev
pool:
vmImage: 'macos-latest'
steps:
- task: Gradle#2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
tasks: 'assembleRelease'
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.apk'
apksignerKeystoreFile: 'key store file'
apksignerKeystorePassword: '$(keyPassword)'
apksignerKeystoreAlias: 'alias'
apksignerKeyPassword: '$(keyPassword)'
- task: CopyFiles#2
inputs:
SourceFolder: '$(Agent.BuildDirectory)'
Contents: '**/*.apk'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'artifact'
publishLocation: 'Container'
- task: AppCenterDistribute#3
inputs:
serverEndpoint: 'VSAC'
appSlug: 'app slug'
appFile: '**/*.apk'
symbolsOption: 'Android'
releaseNotesOption: 'input'
releaseNotesInput: 'CICD Release Build'
destinationType: 'groups'
distributionGroupId: 'dist group id'

Nuget package not available in artifact

I am trying to push private nuget package via azure pipeline. There is no error but i cant see artifact being published in my feed. Here is my yml file. What am i doing wrong here or what can i add?
name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
version.MajorMinor: '4.0'
version.Revision: $[counter(variables['version.MajorMinor'], 0)]
versionNumber: '$(version.MajorMinor).$(version.Revision)'
steps:
- task: CmdLine#2
inputs:
script: 'dir'
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: 'MyProj.csproj'
- task: PowerShell#2
displayName: Set the name of the build (i.e. the Build.BuildNumber)
inputs:
targetType: 'inline'
script: |
[string] $buildName = "$(Build.SourceBranchName)_$(versionNumber)"
Write-Host "Setting the name of the build to '$buildName'."
Write-Host "##vso[build.updatebuildnumber]$buildName"
- task: DotNetCoreCLI#2
displayName: "dotnet pack"
inputs:
command: 'pack'
packagesToPack: 'MyProj.csproj'
nobuild: true
versioningScheme: 'byEnvVar'
versionEnvVar: 'versionNumber'
packDestination: '$(Build.ArtifactStagingDirectory)'
- task: NuGetCommand#2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'XXXXXXXXX/YYYYYYYYYYYY'
allowPackageConflicts: true
To publish to an Azure Artifacts feed, set the Project Collection Build Service identity to be a Contributor on the feed. And add the following snippet to your azure-pipelines.yml file.
steps:
- task: NuGetAuthenticate#0
displayName: 'NuGet Authenticate'
- task: NuGetCommand#2
displayName: 'NuGet push'
inputs:
command: push
publishVstsFeed: '<projectName>/<feed>'
allowPackageConflicts: true
Refer to the documentation here:
https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/nuget?view=azure-devops&tabs=yaml