Search code examples
azure-devopsazure-pipelines

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.

First Attempt

Deploy Stage Not Started

Job is Pending

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)'

Solution

  • I had the same error. I renamed - deployment: Deploy to - deployment: Deployment ...and it started to work.