首页 > 解决方案 > hcsshim::System::CreateProcess 期间遇到错误:Windows 系统调用失败:系统找不到指定的文件。(0x2)

问题描述

我正在从 Jenkinsfile 运行 docker 映像,jenkinsfile 中的 docker 命令如下命令 -

> docker run --name "Test_Windows_Name" -v
> C:\Jenkins\workspace\Test_Windows:"C:\workspace" -t
> xyz/windows/dependencycheckwindows:latest -projectName "DotNet_2017"
> -projectRoot "C:\workspace\Web\DotNet_2017\WebApplication1" -jobName "Test_Windows_Job" -buildNumber "16"

While running the Jenkinsfile, I am getting below error -

> docker: Error response from daemon: container
> 250fa4616cf0695b9ece7603cdf28e062ifad23eb7f4abc6da63a0f6796802d2
> encountered an error during hcsshim::System::CreateProcess: failure in
> a Windows system call: The system cannot find the file specified.
> (0x2) extra info: {"CommandLine":"python run_windows.py -projectName
> DotNet_2017 -projectRoot
> C:\\workspace\\Web\\DotNet_2017\\WebApplication1 -jobName
> Test_Windows_Job -buildNumber
> 16","WorkingDirectory":"C:\\pythonapp","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[0,0]}.

Please help in resolving the issue.

Here is the dockerfile code -
    FROM mcr.microsoft.com/windows/servercore:ltsc2019
    RUN SETX version_url "https://jeremylong.github.io/DependencyCheck/current.txt"
    RUN SETX download_url "https://dl.bintray.com/jeremy-long/owasp"
    RUN mkdir C:\staging
    RUN echo %version_url% > C:\staging\version.txt
    RUN powershell.exe -c "invoke-webrequest 'https://jeremylong.github.io/DependencyCheck/current.txt' -O C:\staging\current.txt"
    RUN SETX file "dependency-check-%current.txt%-release.zip"
    RUN echo %file% > C:\staging\file.txt
    RUN SETX url "%download_url% + '/' + %file%"
    RUN echo %url% > C:\staging\url.txt
    WORKDIR C:\\staging
    ENTRYPOINT ["CMD"]

这是 JenkinsFile 代码 -

> pipeline {
>         agent { label 'windows' }
>         environment {
>           docker_repo = 'xyz.compute.amazonaws.com:8083'
>     
>             docker_image = "${docker_repo}/xyz/sast/windows/dependencycheckwindows:latest"
>          }
>     
>            stages {
>             stage('Setup') {
>                 steps {
>                   withCredentials([usernamePassword(credentialsId: 'id',

用户名变量:'用户',密码变量:'密码')]){

                bat 'echo "Connecting with Git repository"'
                bat 'git config --global credential.helper cache'
                bat 'git config --global user.email "${user}@dummy.com"'
                bat 'git config --global user.name "${user}"'
              }
              withCredentials([usernamePassword(credentialsId: 'Repo_id',

usernameVariable: 'Repo_user', passwordVariable: 'Repo_password')]){ bat 'echo "连接 Nexus 存储库"' bat "docker login --username=${Repo_user} --password=${Repo_password} ${env.docker_repo }"
} } } stage('Run OWASP Dependency Check scan') { steps { bat ''' echo "Starting Docker Image" docker pull %docker_image% docker run --name "%JOB_NAME%" -v %workspace%:"C: \workspace" -t %docker_image% -projectName "DotNet_2017" -projectRoot "C:\workspace\Web\DotNet_2017\WebApplication1" -jobName "%JOB_NAME%" -buildNumber "%BUILD_NUMBER%" ''' } } } post { always {
archiveArtifacts artifacts: 'artifacts\*.log',fingerprint: true bat ''' echo '清理环境。' docker stop -t 0 "%JOB_NAME%" docker rm "%JOB_NAME%" docker rmi %docker_image% docker system prune -f set reportfile=%JOB_NAME%-%BUILD_NUMBER%.xml 如果不存在 artifacts\%reportfile% exit 1 ' ''archiveArtifacts artifacts: 'artifacts\*.xml', 指纹: true } success { println('I succeeeded!'

标签: dockerdockerfile

解决方案


推荐阅读