安装程序是在Kubernetes中运行的Jenkins。我想整理代码,运行测试,然后构建一个容器。在我的构建步骤之一中无法安装/运行诗歌。
podTemplate(inheritFrom: 'k8s-slave', containers: [
containerTemplate(name: 'py38', image: 'python:3.8.4-slim-buster', ttyEnabled: true, command: 'cat')
])
{
node(POD_LABEL) {
stage('Checkout') {
checkout scm
sh 'ls -lah'
}
container('py38') {
stage('Poetry Configuration') {
sh 'apt-get update && apt-get install -y curl'
sh "curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python"
sh "$HOME/.poetry/bin/poetry install --no-root"
sh "$HOME/.poetry/bin/poetry shell --no-interaction"
}
stage('Lint') {
sh 'pre-commit install'
sh "pre-commit run --all"
}
}
}
}
诗歌安装工作正常,但是当我去激活外壳程序时,它会失败。
+ /root/.poetry/bin/poetry shell --no-interaction
Spawning shell within /root/.cache/pypoetry/virtualenvs/truveris-version-Zr2qBFRU-py3.8
[error]
(25, 'Inappropriate ioctl for device')
答案 0 :(得分:2)
这里的问题是Jenkins运行非交互式Shell,而您正在尝试启动交互式Shell。 --no-interaction
选项并不意味着非交互式外壳,而是外壳不询问您问题:
-n (--no-interaction) Do not ask any interactive question
我不会调用shell,而只使用poetry run
??命令:
podTemplate(inheritFrom: 'k8s-slave', containers: [
containerTemplate(name: 'py38', image: 'python:3.8.4-slim-buster', ttyEnabled: true, command: 'cat')
])
{
node(POD_LABEL) {
stage('Checkout') {
checkout scm
sh 'ls -lah'
}
container('py38') {
stage('Poetry Configuration') {
sh 'apt-get update && apt-get install -y curl'
sh "curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python"
sh "$HOME/.poetry/bin/poetry install --no-root"
}
stage('Lint') {
sh "$HOME/.poetry/bin/poetry run 'pre-commit install'"
sh "$HOME/.poetry/bin/poetry run 'pre-commit run --all'"
}
}
}
}
✌️</ p>
答案 1 :(得分:0)
在容器级别安装诗歌,然后使用以下内容解析poetry.lock文件
poetry export --without-hashes --dev -f requirements.txt -o requirements.txt
然后使用pip install -r requirements.txt
的{{1}} INSTEAD安装依赖项
然后,您不必在虚拟环境中运行命令。