Skip to content

Execute commands in Python virtualenvs in Jenkins Pipeline DSL

License

Notifications You must be signed in to change notification settings

giddyinc/pyenv-pipeline-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pyenv Pipeline Plugin

A Jenkins plugin that provides a way to execute sh and bat Pipeline DSL commands within a specified Python virtualenv.

Overview

This plugin provides 3 new Pipeline DSL methods:

  • withPythonEnv: Specifies a Python virtualenv to execute any pysh and pybat DSL commands contained within its block.

    withPythonEnv takes a single String argument, which specifies the Python executable to use for the virtualenv. pyenv-pipeline will use the executable to generate a corresponding virtualenv, and store it's location in the PYENVPIPELINE_VIRTUALENV_RELATIVE_DIRECTORY environmental variable.

    The argument provided to withPythonEnv will first attempt to match it against the name of a ToolInstallation that is described by a ToolDescriptor with an ID that is contained within a pre-defined list of known Jenkins Python Tool plugin IDs. Currently, this plugin only looks to see if ShiningPanda is installed. If a ToolInstallation is matched, the location of that tool is used as the Python executable to generate the virtualenv.

    If no ToolInstallation is matched, then the argument is treated as the literal location of the Python executable to be used. This can be used to specify a specific Python installation (if the location is known beforehand), or to fallback and use the systems default Python installation.

    • withPythonEnv('python') {
          // Uses the default system installation of Python
          // Equivalent to withPythonEnv('/usr/bin/python') 
          // or withPythonEnv('/usr/bin') on Ubuntu
          ...
      }
      
    • withPythonEnv('/usr/bin/python3.5') {
          // Uses the specific python3.5 executable located in /usr/bin
          ...
      }
    • withPythonEnv('CPython-2.7'){
          // Uses the ShiningPanda registered Python installation named 'CPython-2.7'
          ...
      }
  • pysh: Functions as the provided sh Pipeline DSL command, expect that if it finds the PYENVPIPELINE_VIRTUALENV_RELATIVE_DIRECTORY environmental variable, it activates the virtualenv located there prior to running the provided script.

  • pybat: Works just like pysh, expect for Windows build environments

About

Execute commands in Python virtualenvs in Jenkins Pipeline DSL

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 97.8%
  • HTML 2.2%