In declarative pipelines we set up docker agent as below,
pipeline {
agent {
docker {
image dockerImage
args dockerArgs
registryUrl dockerRegistryUrl
registryCredentialsId dockerRegistryCredentialsId
label dockerLabel
alwaysPull true
}
}
....
but I want to do something like this,
def dockerAgent = new Docker(dockerImage, dockerArgs,...)
pipeline {
agent {
dockerAgent
}
}
....
The intention is to generate Docker Agent with the properties using a shard-lib and inject the agent to the pipeline. Is this possible to do?