I am using the declarative format for pipeline files and running inside of a docker container that is defined using a Dockerfile in my project's root directory.
My Jenkinsfile looks like this:
pipeline {
agent {
dockerfile {
additionalBuildArgs '--network host'
}
}
stages {
stage('Test') {
steps {
sh 'pytest --version'
}
}
}
I would like to pass additional arguments to the docker run command similar to this question ... How to pass docker container arguments when running the image in a Jenkinsfile
Is it possible to do that in the declarative pipeline format, or should I switch?
Edit:
This is essentially the equivalent of what I am trying to do in non-declarative:
node {
def pytestImage = docker.build('pytest-image:latest', '--network host .')
pytestImage.inside('--network=host') {
sh 'pytest --version'
// other commands ...
}
}