我想在一个容器中运行我的构建,其图像由源代码控制下的文件确定,所以类似于
environment {
my_image = ...
}
agent {
docker {
image my_image
}
}
但詹金斯抱怨说
groovy.lang.MissingPropertyException: No such property: my_image for class: groovy.lang.Binding
有没有办法让 Jenkins 使用 docker 镜像规范的变量?
完整管道供参考:
pipeline {
agent any
environment {
REPO = 'unknown'
}
stages {
stage('toolchain') {
steps {
git 'https://github.com/avikivity/jenkins-docker-test'
script {
REPO = readFile 'repo'
}
echo "repo = ${REPO}"
}
}
stage('build') {
agent {
docker {
image REPO
//image 'docker.io/scylladb/scylla-build-dependencies-docker:fedora-29'
label 'packager'
}
}
steps {
git 'https://github.com/avikivity/jenkins-docker-test'
sh './build'
}
}
}
}