I am running the docker image from Jenkinsfile, the docker command in jenkinsfile is as following command -
> 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"]
Here is the JenkinsFile code -
> 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: 'user', passwordVariable: 'password')]){
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 "Connecting with Nexus repository"' 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 'Cleaning up the environment.' 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 if not exist artifacts\%reportfile% exit 1 ''' archiveArtifacts artifacts: 'artifacts\*.xml', fingerprint: true } success { println('I succeeeded!') } unstable { println('I am unstable :/') } failure { println('I failed :(') } changed { println('Things were different before...') } } }