How to execute powershell script from jenkins by passing parameters - powershell

I have a powershell script in my Github. i am trying to execute that via Jenkins. Here is a part of the script :-
param (
+ [string]$fileDir = "%WORKSPACE%\src\Project\***",
[string]$packagingDir = "%WORKSPACE%\src\packageTemp",
[string]$staticFilesToDeploy = "%WORKSPACE%\src\****"
)
Now i am using a simple batch execution within Jenkins Job to run this script. I am trying to run it as
powershell -noexit "& ""%WORKSPACE%\src\***.ps1"""
But when Jenkins actually executes this powershell script its unable to replace %workspace% within the script and fails as it cannot find that. How do i make jenkins to replace that within the script when it executes it actually

I was able to get this resolved by passing arguments for the powershell script through jenkins :-
powershell.exe -file "%WORKSPACE%\src\***.ps1" -fileDir "%WORKSPACE%\src\Project\***" -packagingDir "%WORKSPACE%\src\packageTemp" -staticFilesToDeploy "%WORKSPACE%\src\****"
This force sets the values for the params within the script at run time and at the same time can be issued via jenkins to be able to make use of its environment variables.

Related

Jenkins to call powershell script but doesn't execute

Is there a way wherein Jenkins call a powershell script and just stops without waiting for an output? I don't want it to run under the context of jenkins. Jenkins would be used ONLY to pass the form parameters.
Reason : Jenkins doesn't work quite well with Internet explorer COM objects because script works fine when called directly or task scheduler but fails using Jenkins at few steps. Tried multiple work-around but failed.
So, the resolution is that I would call the script using Jenkins only so that it runs under the context of powershell only. Jenkins would be used ONLY to pass the form parameters.
Regards,
Rahul
powershell Start-Job command should work
powershell script: '''
Start-Job {
param($someArgument)
// set location as current directory
Set-Location $using:PWD
//start a command
PowerShell -NoProfile -ExecutionPolicy Bypass -Command .\myscript.ps1
} -Name "myJob1" -ArgumentList $someArgument
'''

I would like to execute my powershell script in Jenkins and show results OK/NOK

I would like to execute my powershell scripts. To do this I've written a basic jenkinsfile. However, Jenkins constantly complains about either a unexpected '\' character or it simply says that the path I've given is not the OK. Or that the cmdlet is not properly used.
I've tried:
call '& "C:\WSEB\Conversietool\UT\ConversieToolTestcases\CommandLineConversieALLtestcases.ps1"'
powershell '& "C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\KopieerToolUitvoerVorigeTestrun.ps1"'
powershell '& C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\KopieerToolUitvoerVorigeTestrun.ps1
& C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\KopieerConfig-test.ps1
& C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\VerwijderResultaten.ps1'
call 'C:\\WSEB\\Conversietool\\UT\\ConversieToolTestcases\\CommandLineConversieDSO.ps1'
powershell 'C:\WSEB\Conversietool\UT\ConversieToolTestcases\CommandLineConversieALLtestcases.ps1'
I'm at a loss here. I would like Jenkins to simply tell me if the tests were OK/NOK (warnings/errors etc). The powershell files are located in C:\WSEB\Conversietool\UT\ConversieToolTestcases
I've got it. You can execute a powershell script file with the following:
powershell returnStatus: true, script: 'C:\\Users\\User\\Desktop\\example.ps1'
Credits to: bic (Run Powershell script from file in Jenkins pipeline)

Powershell script not running through Informatica Powercenter

I have a Powershell script which runs perfectly directly on my local machine using Powershell and command line. But when running in post-session command in Informatica, it is not getting executed, only the session gets succeeded. I am calling bat script using this command- $PMRootDir\Scripts\GetColumns.bat . And this bat script is further invoking Powershell script. Need help on this.

Execution of TestComplete automation scripts through powershell using TFS Release Management

Unable to run TestComplete scripts through powershell script using TFS Release Management task "Powershell on Target Machines".
The task is initiated in Release management and never completes. Are there any special arguments to be passed to powershell script in order to execute the test script interactively.
Manually running the powershell script on the release agent machine executes without any issue.
The Script argument are the arguments required by the script, if any.
-NoProfile is an argument which powershell.exe accepts, try removing that.

How to Execute a PowerShell Script from SSIS

Does anyone know how to execute a PowerShell script from SSIS? I have created the script and it works from from the command line. The script takes a couple of command line parameters, which work fine when called from cmd.exe.
I'm using an Execute Process Task in SSIS and cannot get the script file to execute. I'm using expressions to pass in the name of the script and the command line arguments. The task is returning an incomplete string token error.
From VS to launch PSH with an extra script (for a Cmdlet project) I use the following commandline:
powershell -noexit -command ". ./Startup.ps1"
The -noexit will keep the instance around (so you wouldn't want that), putting all the real commands in a script to be dot-sourced avoids a really long command line.
Go to Execute Process Task Editor -> Process tab and set the following options:
Executable - C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments - -File ".\PowershellScript/ps1" "arg_1_value" "arg_2_value" ... "arg_n_value"
Refer to the below screenshot: