I would like to tag my docker image with second tag (php minor version).
stage("Build") {
matrix {
agent {
docker {
image "php:${PHP_VERSION}-fpm"
}
}
axes {
axis {
name "PHP_VERSION"
values "8.0", "8.1", "8.2"
}
}
stages {
stage('Check version php:${PHP_VERSION}-fpm') {
steps {
script {
php80php = sh (
script: "php -r 'echo PHP_VERSION;'",
returnStdout: true
).trim()
echo "${phpminorversion}"
}
}
}
stage("Build image") {
steps {
sh """
docker buildx build --target php-fpm --build-arg PHP_TYPE=fpm --build-arg PHP_VERSION=${PHP_VERSION} --push --platform linux/amd64,linux/arm64 -t my_image/php-fpm:${PHP_VERSION} -t droptica/php-fpm:${phpminorversion} --no-cache .
"""
}
}
stage('php version') {
agent {
docker { image "my_image/php-fpm:${PHP_VERSION}" }
}
steps {
script {
sh 'php -version'
}
}
}
}
}
}
}
The matrix seems to be working:
But in stage Build image something is wrong. Firstly, it substitutes version 8.2.7 for each major PHP version, secondly, line 2 error: docker: not found