首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在jenkinsfile中运行诗歌

在jenkinsfile中运行诗歌
EN

Stack Overflow用户
提问于 2020-07-18 04:25:48
回答 2查看 1.4K关注 0票数 1

安装程序是在Kubernetes中运行的Jenkins。我想编写代码,运行测试,然后构建一个容器。在我的一个构建步骤中安装/运行poetry时遇到了问题。

代码语言:javascript
复制
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时,它失败了。

代码语言:javascript
复制
+ /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')
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-07-18 13:22:36

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

代码语言:javascript
复制
  -n (--no-interaction)  Do not ask any interactive question

This answer explains it??.

我不会调用外壳,而只是使用poetry run??命令:

代码语言:javascript
复制
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'"
            }
        }
    }
}

✌️

票数 3
EN

Stack Overflow用户

发布于 2020-09-15 21:55:57

在容器级别安装poetry,然后使用以下命令解析poetry.lock文件

代码语言:javascript
复制
poetry export --without-hashes --dev -f requirements.txt -o requirements.txt

然后使用pip install -r requirements.txt而不是poetry install安装依赖项

这样你就不必在虚拟环境中运行命令了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62961328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档