python - jenkinsfile中的诗歌

标签 python jenkins kubernetes python-poetry

安装程序是Jenkins在Kubernetes中运行的。我想整理代码,运行测试,然后构建一个容器。在我的构建步骤之一中无法安装/运行诗歌。

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')

最佳答案

这里的问题是, Jenkins (Jenkins)运行非交互式 shell ,而您正在尝试启动交互式 shell 。 --no-interaction选项并不意味着非交互式 shell ,而是该 shell 不询问您问题:

  -n (--no-interaction)  Do not ask any interactive question
This answer explains it🔑🔑。
我只是不叫 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'"
            }
        }
    }
}
✌️

关于python - jenkinsfile中的诗歌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62961328/

相关文章:

amazon-web-services - Kubernetes 中的 NGINX 无法解析 DNS

python - Django 3.1 - "OperationalError: no such table"在进行或应用迁移之前使用 ORM 类模型时

python - mysql python 由于某种原因不更新表

Python Scrapy 函数调用

docker - Jenkins Kubernetes 插件 : How to build image from Dockerfile and run steps inside the image

wordpress - 如何在Kubernetes集群中扩展Wordpress-使用多个Pod副本-访问单个PVC(永久文件存储)

python数据表,列上的字符串操作

curl - Jenkins 无法 curl 到 docker 容器上的 http 端点主机

jenkins - 无法通过 docker 容器执行 ansible playbook

kubernetes - 如何使用 kubectl run 命令创建使用非默认服务帐户的 Pod?