Как создавать образы докеров при запуске docker в качестве агентов jenkins для сборки.
Я пытаюсь понять, как мы можем создавать образы докеров
Jenkins Установлен на виртуальной машине- Centos 7, на этой же машине установлен докер.
pipeline {
agent {
docker {
image 'maven:3.6.2-jdk-11'
}
}
environment {
IMAGE_NAME=readMavenPom().getArtifactId()
BUILD_NUMBER="${env.BUILD_NUMBER}"
GITLAB_URL="xxxx"
IMAGE_VERSION=readMavenPom().getVersion()
GIT_URL="xxxx"
GIT_CRED_ID="xxxx"
DOCKER_REPOURL="xxxx"
}
options {
timestamps()
}
stages {
stage ('Checkout') {
steps {
echo 'Build Started ...'
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/jenkins_build']], browser: [$class: 'GitLab', repoUrl: "${GITLAB_URL}", version: '11.10'], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${GIT_CRED_ID}", url: "${GIT_URL}"]]]
configFileProvider([configFile(fileId: '392b1fe8-8ccd-4b8a-a73b-1d745a6bd03d', variable: MAVEN_GLOBAL_SETTINGS{
sh 'mvn -gs $MAVEN_GLOBAL_SETTINGS clean package '
}
}
}
stage('Publish') {
steps {
echo 'Build and Deploy to Nexus ...'
withDockerRegistry(credentialsId: 'nexus_docker_creds', url: 'xxxxxx') {
sh '''
docker --version
docker build -t "${DOCKER_REPOURL}"/"${IMAGE_NAME}":"${IMAGE_VERSION}"
'''
}
}
}
}
}
[Pipeline] withDockerRegistry
14:53:32 $ docker exec --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** --env ******** 9a2be9d46c2f9961d1852d2322e64a20a1b4bade1c55d297f4f1d2d2943cc7b4 docker login -u admin -p ******** https://xxxxx
14:53:34 OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"docker\": executable file not found in $PATH": unknown
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
$ docker stop --time=1 9a2be9d46c2f9961d1852d2322e64a20a1b4bade1c55d297f4f1d2d2943cc7b4
$ docker rm -f 9a2be9d46c2f9961d1852d2322e64a20a1b4bade1c55d297f4f1d2d2943cc7b4
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: docker login failed
Finished: FAILURE