As I understand you want to add a variable to yourthe docker build commandimage tag,
in this case, you have to get an environment variable from Jenkins and use it in your image label.
pipeline {
agentpipeline {
dockerenvironment {
registry image= 'maven:3-alpine'"docker_hub_account/repository_name"
registryCredential label= 'my-defined-label-${BUILDS_ALL_TIME}''dockerhub'
args '-v /tmp:/tmp'}
agent }
}any
stages {
stage('Example'Building Build'image') {
steps {
script {
sh '#some command'
docker.build registry + ":$BUILD_NUMBER"
}
}
}
}
}
pleae use this URL for more info