Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46359

Create a "python" step which can run Python code directly in pipeline

XMLWordPrintable

      Similar to the sh step, it would be useful to have a build step which can execute python code directly inside a pipeline.  I process the following addition to the durable-task-plugin.

      Create a python pipeline command to run Python scripts directly.

      Syntax:

      node {
      
      python """
           from datetime import datetime
           now = datetime.now() 
           print("CURRENT TIME: ", now)
       """
       }
      

      The command should support two optional parameters:

      1.  virtualenv: If set, this should prepend a directory to PATH:
        On Windows:

      ${virtualenv}/scripts

      On POSIX (Linux, MacOS X, FreeBSD, etc.):

      ${virtualenv}/bin

      1. executable: This value allows the user to specify the full path
        to the Python executable. This is equivalent to
        the Python sys.executable variable.
        If not set, the default value of this should be: "python".
        This would allow the user to use non-default python interpreters, such as /usr/local/bin/python3 or /opt/bin/pypy

       

      Optionally, the Python script should run under setsid() on POSIX platforms, to make it easier to stop/kill  Python scripts started in Pipelines ( JENKINS-25503 ). 

       

            Unassigned Unassigned
            rodrigc Craig Rodrigues
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: