安装程序是在Kubernetes中运行的Jenkins。我想编写代码,运行测试,然后构建一个容器。在我的一个构建步骤中安装/运行poetry时遇到了问题。
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"
}
}
}
}诗歌安装可以正常工作,但是当我激活shell时,它失败了。
+ /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')发布于 2020-07-18 13:22:36
这里的问题是,Jenkins运行一个非交互式shell,而您正在尝试启动一个交互式shell。--no-interaction选项并不意味着非交互式shell,而是shell不会问您问题:
-n (--no-interaction) Do not ask any interactive question我不会调用外壳,而只是使用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'"
}
}
}
}✌️
发布于 2020-09-15 21:55:57
在容器级别安装poetry,然后使用以下命令解析poetry.lock文件
poetry export --without-hashes --dev -f requirements.txt -o requirements.txt然后使用pip install -r requirements.txt而不是poetry install安装依赖项
这样你就不必在虚拟环境中运行命令了。
https://stackoverflow.com/questions/62961328
复制相似问题