jfrog / jenkins-jfrog-plugin

Easy integration between Jenkins and the JFrog Platform.
https://github.com/jfrog/jenkins-jfrog-plugin
Apache License 2.0
39 stars 17 forks source link

Add support for virtual environments for pip install commands #88

Open bewczardski opened 6 months ago

bewczardski commented 6 months ago

Is your feature request related to a problem? Please describe.

When using the JFrog Plugin in a python build pipeline, dependencies cannot be installed into a virtual environment.

When using the jfrog-cli locally this is possible.

Describe the solution you'd like to see

Provide a mechanism to allow virtual environment activation during the jf 'pip install' command. The JFrog Artifactory plugin provided this functionality.

Describe alternatives you've considered

PipEnv and Poetry are supported, but the JFrog Plugin should support standard tool workflows.

Additional context

Here is a simple workflow highlighting the problem. The end result is the virtual environment does not contain the jinja2 package

pipeline {
    agent {
        kubernetes {
            inheritFrom 'k8s-agent'
            yamlMergeStrategy merge()
            defaultContainer 'python'
            yaml """\
                spec:
                  containers:
                    - name: python
                      image: python:3.12-slim-bookworm
                      imagePullPolicy: Always
                      command:
                        - cat
                      tty: true
                      resources:
                        requests:
                          cpu: 250m
                          memory: 512Mi
                        limits:
                          cpu: 500m
                          memory: 512Mi
                    """.stripIndent()
        }
    }
    tools {
        jfrog 'jfrog-cli'
    }
    stages {
        stage('Install Dependencies') {
            steps {
                sh 'python -m venv venv && . venv/bin/activate'
                jf 'pip-config --repo-resolve=pypi-dev'
                jf 'pip install jinja2'
                sh '. venv/bin/activate && pip list'
            }
        }
    }
}