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

Jenkins parameters in Python plugin

    Details

    • Similar Issues:

      Description

      Hi,

      I am not able to take the Jenkins Parameter values in Execute Python Script. Usually, Execute shell takes the parameters as such.

      Example:
      Parameter -> EMAIL:abc@example.com

      I can access this parameter as $EMAIL in Execute shell but failed to print the value through Execute Python Script which is Python Plugin.

      This facility of importing Jenkins parameter is not available for this plugin? If so, is there any way to import the parameters?

      Regards,
      Mahesh

        Attachments

          Activity

          Hide
          jhasse Jan Niklas Hasse added a comment -

          How did you try to print it?

          Show
          jhasse Jan Niklas Hasse added a comment - How did you try to print it?
          Hide
          mahesh_18389 Mahesh N added a comment -

          by normal print statement

          Show
          mahesh_18389 Mahesh N added a comment - by normal print statement
          Hide
          jhasse Jan Niklas Hasse added a comment -

          Like this?

          print(os.environ['EMAIL'])

          Show
          jhasse Jan Niklas Hasse added a comment - Like this? print(os.environ ['EMAIL'] )
          Hide
          mahesh_18389 Mahesh N added a comment -

          Oh No..! print EMAIL like echo....

          It worked

          But Why is it so? All the input parameters are considered as env variables while running that job?

          Show
          mahesh_18389 Mahesh N added a comment - Oh No..! print EMAIL like echo.... It worked But Why is it so? All the input parameters are considered as env variables while running that job?
          Hide
          jhasse Jan Niklas Hasse added a comment -

          Shell scripts use $ to access environment variables. In Python you have to use the os.environ dictionary

          Show
          jhasse Jan Niklas Hasse added a comment - Shell scripts use $ to access environment variables. In Python you have to use the os.environ dictionary
          Hide
          mahesh_18389 Mahesh N added a comment -

          ok. Thanks Jan

          Show
          mahesh_18389 Mahesh N added a comment - ok. Thanks Jan

            People

            • Assignee:
              jhasse Jan Niklas Hasse
              Reporter:
              mahesh_18389 Mahesh N
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: