我正在从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',
usernameVariable:“用户”,passwordVariable:“密码”)]){
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}”
} } } 阶段(“运行OWASP依赖性检查扫描”){ 脚步 { 蝙蝠''' 回声“启动Docker映像” 码头工人拉%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%” ''' } } } 发表{ 总是{
archiveArtifacts工件:“ artifacts \ *。log”,指纹:true 蝙蝠''' 回声“清理环境”。 docker stop -t 0“%JOB_NAME%” 码头工人rm“%JOB_NAME%” docker rmi%docker_image% 码头工人系统修剪-f 设置reportfile =%JOB_NAME%-%BUILD_NUMBER%.xml 如果不存在工件\%reportfile%退出1 ''' archiveArtifacts工件:“ artifacts \ *。xml”,指纹:true } 成功{ println('我成功了!') } 不稳定{ println('我很不稳定:/') } 失败{ println('我失败了:(') } 更改了{ println('事情在...之前是不同的') } } }