Unable to pip install in Docker image as agent through Jenkins declarative pipeline

后端 未结 3 1929
有刺的猬
有刺的猬 2021-02-15 06:34

I have yet another issue with permissions running Docker through Jenkins declarative pipeline. I want to build and publish a Python package through a Jenkins job in a D

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 07:08

    I have found what I myself would think is the prettier solution:

    stage("Python Test") {
      agent { 
        docker {
          label "docker && linux" 
          image "python:3.7"
        }
      }
      steps {
        withEnv(["HOME=${env.WORKSPACE}"]) {
          sh "pip install -r requirements.txt --user"
          # python stuff
        }
      }
      post {
        cleanup {
          cleanWs()
        }
      }
    }
    

    This workaround steers completely around the issue itself, installing the packages at user level. The issue here was that the HOME-directory was not initially writeable either, thus overwriting the HOME directory.

提交回复
热议问题