【发布时间】:2017-08-31 16:45:29
【问题描述】:
我无法让 python3 在 jenkins 中工作。 Jenkins 目前正在一个 docker 容器中运行,我正在使用pipeline 脚本来促进 CI/CD
这是我的Jenkinsfile 用于 python 回购
pipeline {
agent any
tools {
nodejs 'nodejs'
python3 'python3'
}
environment{
}
stages {
stage('build'){
steps{
echo 'Preparing'
sh 'python3 --version'
sh 'pip3 install -U pytest'
script{
// pull git tag and add to a variable to set the build info - {tag#build_no}
GIT_TAG = sh(script: "git describe --abbrev=0 --tags", returnStdout: true).trim()
sh 'echo ${GIT_TAG}'
currentBuild.displayName = "${GIT_TAG}#${BUILD_NUMBER}"
}
}
}
stage('Checkout'){
steps {
echo 'Checking out code from repo'
checkout scm
}
}
stage('install'){
steps{
echo 'installing libraries'
sh 'pip3 install -r requirements.txt'
}
}
stage('test'){
steps {
echo 'running tests'
sh 'pytest'
}
post{
success{
bitbucketStatusNotify(buildState: 'SUCCESSFUL')
office365ConnectorSend message: "The build was successfull", status: "Success", webhookUrl: "${env.HOOK}"
}
failure{
bitbucketStatusNotify(buildState: 'FAILED')
office365ConnectorSend message: "The build has failed", status: "Failure", webhookUrl: "${env.HOOK}"
}
}
}
}
}
jenkins 无法识别python3,因为它尚未安装。如何在我的 jenkins 文件夹中安装 python3?我尝试在这里进行更改 - 但由于某种原因 - 这似乎不起作用(使用 shiningpanda 插件)
python2.7 实际上确实存在于/usr/bin/python 中,但这似乎未被 Jenkins 识别
【问题讨论】:
-
您是否尝试过安装
python3以及位于/usr/bin/python3的主目录或可执行文件?无论如何,我认为您可能需要将python3安装在您的 Jenkins 机器(您的容器映像)中 -
如何做到这一点?我尝试进入 docker 容器并手动安装 python3 可执行文件,但出现以下错误 -
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?- 但sudo在 docker 容器中不起作用:( -
你应该在镜像构建时进行(例如你的 Docker 文件)
-
根据issues.jenkins-ci.org/browse/JENKINS-29007看来Jenkins目前不支持python3?..
-
@Kannaj 你设法让它工作了吗?我和你的情况一样。詹金斯为每项工作都启动了一个容器,但我不知道如何将 python“升级”到版本 3 或“安装”它......它现在只有版本 2..希望您有答案,因为这是一篇旧帖子...谢谢!