jfrog / build-info

Artifactory's open integration layer for CI build servers
https://www.buildinfo.org
Apache License 2.0
147 stars 155 forks source link

Regression: PipInstall fails when envActivation is provided #719

Open nickajacks1 opened 1 year ago

nickajacks1 commented 1 year ago

Describe the bug Triggered by #677 When an envActivation is given to PipInstall, a PipDriver is created with the command set to envActivation + " && pip". PipDriver then forwards this to CommandExecutor, setting the executablePath to the said value. CommandExecutor escapes the spaces, treating the whole string like a single executable. e.g. /bin/sh -c source\ env/bin/activate\ &&\ pip"

To Reproduce Using a Jenkins Pipeline with the Artifactory plugin version 3.18.0, eg

pipeline {
  stages {
    stage('Pip Install') {
      steps {
        sh 'python3 -m venv env'
        rtPipResolver (
          id: 'PipResolver',
          serverId: 'my-server',
          repo: 'my-repo'
        )
        rtPipInstall(
          resolverId: 'PipResolver',
          args: 'pytest black',
          envActivation: '. env/bin/activate'
      }
    }
  }
}

Expected behavior Users should be able to pass an envActivation to PipInstall.

Example Failure on Jenkins Note the escaped spaces.

  INFO: Executing command: /bin/sh -c .\ env/bin/activate\ &&\ pip install .[dev] build -i https://myartifactory.com/pip-local/simple
  org.jfrog.build.extractor.packageManager.PackageManagerLogger error
  SEVERE: pip install failed: /bin/sh: . env/bin/activate : not found

  java.io.IOException: pip install failed: /bin/sh: . env/bin/activate : not found

    at org.jfrog.build.extractor.pip.PipDriver.install(PipDriver.java:36)
    at org.jfrog.build.extractor.pip.extractor.PipInstall.execute(PipInstall.java:98)
    at org.jfrog.build.extractor.packageManager.PackageManagerExtractor.executeAndSaveBuildInfo(PackageManagerExtractor.java:33)
    at org.jfrog.build.extractor.pip.extractor.PipInstall.main(PipInstall.java:85)
  Caused by: java.io.IOException: /bin/sh: . env/bin/activate : not found

Versions

nickajacks1 commented 1 year ago

Any chance this will get traction?

jayeshmurli commented 1 year ago

+1 we have got the same issue after recently upgrading our Jenkins Artifactory plugin.

thehalleffect commented 1 year ago

I'm actually somewhat shocked that this issue doesn't have more comments and upvotes - the primary use case (afaik) for including an envActivation param in a rtPipInstall build step is completely broken by this bug.

nickajacks1 commented 1 year ago

JFrog recommends switching to the JFrog Jenkins plugin, which is a simple wrapper around the JFrog CLI tool. We have done so, and I'd recommend it too, since it's more feature rich, is actively developed, and allows one to more easily run the same code both in the Jenkinsfile and the command line.

That said, this should still be fixed!