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

Run PS Script passing parameters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • powershell-plugin
    • Jenkins 2.332.3
      Powershell Jenkins plugin 1.7

      Hi there,

      I'm trying to run a PS script from a github repo that accept parameters through param() but when I try to pass them with jenkins it fails. I have created a very basic script to prove this. When I call the script withouth parameters it works as espected, but when I try to call it passing one parameter it fails:
      [copla-cli-test0] $ powershell.exe -NonInteractive -ExecutionPolicy Bypass -File C:\Windows\TEMP\jenkins5348470450205503128.ps1
      . : The term 'C:\Windows\Temp\Jenkins\workspace\copla-cli-test0\hellow.ps1 testmessage' is not recognized as the name
      of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
      I have managed to have it working copying the script code in the jenkin's powershell textbox and referencing parameter as $env:parameter but this is not what I need, since we are developing powershell scripts in github I need to call the script something like this:

       

      . "$ENV:WORKSPACE\hellow.ps1 $env:message"
       
      

      I have read something simillar in other Jira issues but didn't helped me much. Is there something I'm missing with powhershell or jenkins? both worlds are relativily new to me.

      Thanks in advance!

       

            froque Filipe Roque
            sunsu alf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: