tinglesoftware / dependabot-azure-devops

Tools for updating dependencies in Azure DevOps repositories using https://dependabot.com
MIT License
189 stars 63 forks source link

The current operating system is not capable of running this task #1242

Open MichaelSchHtc opened 1 month ago

MichaelSchHtc commented 1 month ago

Describe the bug I tried to setup the dependabot on a Azure DevOps Server 2020. I installed the extension (1.30.0.776). I created the dependabot.yml-File and the pipeline. But the task in the pipeline fails immediately with this error: "The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell."

Repository It's a private (self hosted) repo.

Expected behavior I expect the dependabot to complete successfully and create the pull requests to update the old packages.

Extension

Additional context I tried to give the Project Collection Service Accounts all possible permissions. As an Agent pool i use: Ubuntu - 20.04.5 LTS (Focal Fossa). On the agent docker is installed. Docker-Version: 20.10.21, build baeda1f This agent is used for the "normal" builds and works without any problems.

The Output is:

Starting: Run Dependabot
==============================================================================
Task         : Dependabot
Description  : Automatically update dependencies and vulnerabilities in your code
Version      : 1.30.776
Author       : Tingle Software
Help         : For help please visit https://github.com/tinglesoftware/dependabot-azure-devops
==============================================================================
##[error]The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell.
##[debug]System.InvalidOperationException: The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell.
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync()
   at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
Finishing: Run Dependabot

pipeline-yaml:

name: 'Dependabot CI'
trigger: none
stages:
  - stage: CheckDependencies
    displayName: 'Check Dependencies'
    jobs:
      - job: Dependabot
        displayName: 'Run Dependabot'
        pool:
          name: 'LinuxDocker'
        steps:
        - task: dependabot@1
          displayName: 'Run Dependabot'
          inputs:
            failOnException: false

dependabot-yaml:

version: 2
updates:
- package-ecosystem: "npm"
    directories:
      - "/path/to/package.json/" (replaced fo this issue / bug)
    schedule:
      interval: "weekly"
    labels:
      - "dependabot"
      - "dependencies"
mburumaxwell commented 1 month ago

I don't know if it is possible to run a container in another container specifically for Azure DevOps. That's what I gather from the pool named LinuxDocker. Try the hosted agents (the free minutes per month should generally be enough for weekly runs) or an agent that is not a docker container.

MichaelSchHtc commented 1 month ago

The agent itself is not a container. The name (LinuxDocker) is choosen to indicate that docker is available.

mburumaxwell commented 1 month ago

I suggest that you check the setup for the private agent. The only requirements are run on an Agent/DeploymentGroup here, docker be present and discoverable here, and the agent be version be recent here.

MichaelSchHtc commented 1 month ago

All this requirements are fulfilled (Agent-Version is 2.181.2). I also tried it with another agent (that also meets this requirements) but it throws the same Exception.

I guess that I will try a hosted agent.

mburumaxwell commented 1 month ago

The change in #1246 should ideally solve the issue. I released 1.30.2 you can test and report back.

MichaelSchHtc commented 1 month ago

The new version (1.30.2.800) doesn't solve the problem. The same error occurs immediately after starting the dependabot-task.

dependabot_error_20240726
mburumaxwell commented 1 month ago

Could you give an example of some of the "normal" builds that work without any problems? This will be useful to see tasks in them that work for comparison sake.

MichaelSchHtc commented 1 month ago

This is the requested pipeline for a "normal" build:

stages:
  - stage: BuildAndTests (Reducted - here the .NET Solution and the react-app gets build / published on another agent)
  - stage: Docker_Build
    displayName: Docker Build
    pool:
      name: 'LinuxDocker'
    variables:
      NumericVersion: $[ stageDependencies.BuildAndTests.BuildAndTests.outputs['CreateVersionVariable.numericVersion'] ]
    jobs:
      - job: DockerImage
        steps:
        - task: Docker@2
          displayName: 'Build Docker'
          inputs:
            containerRegistry: '<Reducted>'
            repository: '<Reducted>'
            command: 'build'
            Dockerfile: 'src/**/Dockerfile'
            tags: |
              $(Build.BuildNumber)
              latest
            arguments: '--build-arg BUILDNUMBER=$(NumericVersion)'
  - stage: Docker_Deploy
    displayName: Docker Deploy
    pool:
      name: 'LinuxDocker'
    jobs:
      - deployment: <Reducted>
        displayName: Deploy
        environment: '<Reducted>'
        strategy:
          runOnce:
            deploy:
              steps:
                - task: Docker@2
                  displayName: 'Push image'
                  inputs:
                    containerRegistry: '<Reducted>'
                    repository: '<Reducted>'
                    command: 'push'
                    tags: |
                      $(Build.BuildNumber)
                      latest

Perhaps relevant: This features are available on the agent (LinuxDocker)

Agent.Name REDUCTED Agent.Version 2.181.2 _ ./externals/node/bin/node Agent.ComputerName REDUCTED Agent.HomeDirectory REDUCTED Agent.OS Linux Agent.OSArchitecture X64 curl /usr/bin/curl docker /usr/bin/docker dotnet /usr/bin/dotnet git /usr/bin/git HOME REDUCTED InteractiveSession False INVOCATION_ID REDUCTED JOURNAL_STREAM 9:45971 LANG en_US.UTF-8 LOGNAME REDUCTED PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin PWD REDUCTED python /usr/bin/python python3 /usr/bin/python3 sh /bin/sh SHELL /bin/bash