jenkins - How to pass docker container arguments when running the image in a Jenkinsfile -
i have dockerfile ends with
entrypoint ["node", "index.js"] cmd ["--help"]
the index.js
can take couple different arguments , need expose port container if run manually like:
docker run -p 3000:3000 my_container:latest --arg1 somearg --arg2 anotherarg
how do in jenkinsfile? test communicate container needs running before run test. use withrun()
running before test runs don't see how specify --arg1 somearg --arg2 anotherarg
stage('testmicroservice') { // // how specify '--arg1 somearg --arg2 anotherarg'? // docker.image("my_container:latest").withrun('-p 3000:3000') { sh 'npm run test-microservice' } }
you can use second argument of withrun
.withrun('-p 3000:3000', '--arg1 somearg --arg2 anotherarg')
Comments
Post a Comment