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

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

    Details

    • Similar Issues:

      Description

      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 ). 

       

        Attachments

          Activity

          rodrigc Craig Rodrigues created issue -
          rodrigc Craig Rodrigues made changes -
          Field Original Value New Value
          Labels pipeline-improvement
          jglick Jesse Glick made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Won't Do [ 10001 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved: