diff --git a/.gitignore b/.gitignore index 683b1b0..623501c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ scripts/test.ps1 scripts/uipathcli/* +test_scripts/* *.csv *.log - diff --git a/README.md b/README.md index b63ea85..fbcbf2c 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ Until a generic solution is officially released, this unofficial library of DevO - The provisioned vm or agent should be a window machine - Add a step in your CI/CD pipepline to download the descired scripts. (Downlod only the scripts you need, for example if you want to Pack an RPA project then download UiPathPack script) Use the scripts below as one step in your pipeline and give at any name (e.g. "Preparing Environment") - ```PowerShell +It is recommended to download copy of the scripts from the [scripts folder](scripts) into your own repository + ```PowerShell #Create scripts folder under C drive. (you can change the directory path ) New-Item -Path "C:\\" -ItemType "directory" -Name "scripts"; Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathPack.ps1" -OutFile "C:\\scripts\\UiPathPack.ps1"; @@ -26,6 +27,8 @@ Use the scripts below as one step in your pipeline and give at any name (e.g. "P Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathJobRun.ps1" -OutFile "C:\\scripts\\UiPathJobRun.ps1"; Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathRunTest.ps1" -OutFile "C:\\scripts\\UiPathRunTest.ps1"; Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathManageAssets.ps1" -OutFile "C:\\scripts\\UiPathManageAssets.ps1"; + Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathAnalyzeProject.ps1" -OutFile "C:\\scripts\\UiPathAnalyzeProject.ps1"; + Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathCLIGeneric.ps1" -OutFile "C:\\scripts\\UiPathCLIGeneric.ps1"; ``` @@ -54,6 +57,8 @@ Five available scripts can be utilized | [UiPathJobRun](docs/UiPathJobRun.md) | Trigger a job on Orchestrator. Click on the name for detailed documentation | | [UiPathRunTest](docs/UiPathRunTest.md) | Tests a given package or runs a test set. Click on the name for detailed documentation | | [UiPathManageAssets](docs/UiPathManageAssets.md) | Manage uipath orchestrator assets. | +| [UiPathAnalyzeProject](docs/UiPathAnalyzeProject.md) | Check project(s) for workflow analyzer violations | +| [UiPathCLIGeneric](docs/UiPathCLIGeneric.md) | This script is designed for those who know how to work with uipcli.exe and would like to call the cli directly. This script will pass the provided parameters as is directly to uipcli.exe. | --- @@ -76,4 +81,4 @@ Each script will log all output to its own `*.log` file and sometimes to the con * Test Run * asset delete * asset deploy - +* package analyze diff --git a/docs/UiPathAnalyzeProject.md b/docs/UiPathAnalyzeProject.md new file mode 100644 index 0000000..e2e4639 --- /dev/null +++ b/docs/UiPathAnalyzeProject.md @@ -0,0 +1,73 @@ + +# UiPathPack + Check project(s) for workflow analyzer violations +```PowerShell +SYNTAX + . 'C:\scripts\UiPathAnalyzeProject.ps1' [-analyzerTraceLevel ] [-stopOnRuleViolation ] [-treatWarningsAsErrors ] [-saveOutputToFile] [-ignoredRules ] [-orchestratorUrl -orchestratorTenant ] [-orchestratorUsername -orchestratorPassword ] [-orchestratorAuthToken -orchestratorAccountName ] [-orchestratorFolder ] + +Examples: + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" -ignoredRules "ST-NMG-009,ST-DBP-020,UI-USG-011,ST-DBP-020" + . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" -ignoredRules "ST-NMG-009,ST-DBP-020,UI-USG-011,ST-DBP-020" -orchestratorUrl "https://orchestratorurl.com" -orchestratorTenant "default" -orchestratorUsername "username" -orchestratorPassword "\_ye5zG9(x" -orchestratorAuthToken "AuthToken" -orchestratorAccountName "AccountName" -orchestratorFolder "OrchestratorFolder" + + +#Note: if the script folder location is different, you need to replace "C:" with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') +``` + +More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) + +Script Parameters +- `project_path` + Required. Path to a project.json file or a folder containing project.json files. + +- `analyzerTraceLevel` + Specifies what types of messages to output (Off|Error|Warning|Info|Verbose). + +- `stopOnRuleViolation` + Fail the job when any rule is violated. + +- `treatWarningsAsErrors` + Treat warnings as errors. + +- `resultPath` + The full path to a JSON file where the result json file will be created. Otherwise print it to the standard console. + +- `ignoredRules` + (Default: ) A comma-separated list of rules to be ignored by the analysis procedure. + +- `orchestratorUsername` + (Optional, useful only for additional package feeds) The Orchestrator username used for authentication. Must be used together with the password. + +- `orchestratorPassword` + (Optional, useful only for additional package feeds) The Orchestrator password used for authentication. Must be used together with the username. + +- `orchestratorAuthToken` + (Optional, useful only for additional package feeds) The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. + +- `orchestratorAccountName` + (Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. + +- `orchestratorAccountForApp` + (Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +- `orchestratorApplicationId` + (Optional, useful only for additional package feeds) The external application id. Must be used together with account, secret and scope(s) for external application. + +- `orchestratorApplicationSecret` + (Optional, useful only for additional package feeds) The external application secret. Must be used together with account, id and scope(s) for external application. + +- `orchestratorApplicationScope` + (Optional, useful only for additional package feeds) The space-separated list of application scopes. Must be used together with account, id and secret for external application. + +- `orchestratorFolder` + (Optional, useful only for additional package feeds) The Orchestrator folder (organization unit). + +- `orchestratorUrl` + (Optional, useful only for additional package feeds) The Orchestrator URL. + +- `orchestratorTenant` + (Optional, useful only for additional package feeds) The Orchestrator tenant. diff --git a/docs/UiPathAuthenticationsOptions.md b/docs/UiPathAuthenticationsOptions.md new file mode 100644 index 0000000..0ba9e66 --- /dev/null +++ b/docs/UiPathAuthenticationsOptions.md @@ -0,0 +1,6 @@ +## Authentication Options +| Authentication Option | How To | +| ------------- | ------------- | +| External Apps | you will need to retrieve (accountForApp, applicationId, applicationSecret, and applicationScope). Check this link on how to configure External Apps https://docs.uipath.com/orchestrator/docs/managing-external-applications#adding-an-external-application | +| API Access | you will need to retrieve (accountName & UserKey) https://docs.uipath.com/orchestrator/v0/reference/consuming-cloud-api#getting-the-api-access-information-from-the-automation-clouds-ui | +| Username&Password | on-prem orchestrator username & password | \ No newline at end of file diff --git a/docs/UiPathCLIGeneric.md b/docs/UiPathCLIGeneric.md new file mode 100644 index 0000000..6ba7dc1 --- /dev/null +++ b/docs/UiPathCLIGeneric.md @@ -0,0 +1,15 @@ +# UiPathCLIGeneric + This script is designed for those who know how to work with uipcli.exe and would like to call the cli directly. This script will pass the provided parameters as is directly to Uipcli.exe. +```PowerShell +SYNTAX + . 'C:\scripts\UiPathCLIGeneric.ps1' + +Examples: + . 'C:\scripts\UiPathCLIGeneric.ps1' package pack "C:\UiPath\Project\project.json" -o "C:\UiPath\Package" + . 'C:\scripts\UiPathCLIGeneric.ps1' job run ProcessName "https://uipath-orchestrator.myorg.com" default -u admin -p 123456 + . 'C:\scripts\UiPathCLIGeneric.ps1' robot connect machine-name "https://uipath-orchestrator.myorg.com" default -u admin -p 123456 -o OurOrganization -l en-US + . 'C:\scripts\UiPathCLIGeneric.ps1' machine provision MachineNameExample Template "https://uipath-orchestrator.myorg.com" default -u admin -p 123456 -o ModernFolder -l en-US + . 'C:\scripts\UiPathCLIGeneric.ps1'app install Studio -m UiPathStudio.msi + +#Note: if the script folder location is different, you need to replace "C:" with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') +``` diff --git a/docs/UiPathDeploy.md b/docs/UiPathDeploy.md index 0dcf4ca..9d810b1 100644 --- a/docs/UiPathDeploy.md +++ b/docs/UiPathDeploy.md @@ -3,15 +3,20 @@ Deploy packages to an Orchestrator instance, optionally publishing them to a set of environments. ```PowerShell SYNTAX - . 'C:\scripts\UiPathDeploy.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-environment_list ] [-language ] + . 'C:\scripts\\UiPathDeploy.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-environment_list ] [-language ] Examples: - . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project 1" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 - . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization - . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount - . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -environment_list SAPEnvironment,ExcelAutomationEnvironment -language en-US + . 'C:\scripts\\UiPathDeploy.ps1' "C:\UiPath\Project 1" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 + . 'C:\scripts\\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization + . 'C:\scripts\\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -environment_list SAPEnvironment,ExcelAutomationEnvironment -language en-US + . 'C:\scripts\\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount + . 'C:\scripts\\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" + . 'C:\scripts\\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -environment_list SAPEnvironment,ExcelAutomationEnvironment -language en-US -entryPoints EntryPoint1,EntryPoint2 -#Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') +#Note: if script path is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') ``` + +More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) + Script Parameters - `packages_path` Required. The path to a folder containing packages, or to a package file. @@ -34,6 +39,18 @@ Script Parameters - `account_name` Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. +- `accountForApp` + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +- `applicationId` + The external application id. Must be used together with account, secret and scope(s) for external application. + +- `applicationSecret` + The external application secret. Must be used together with account, id and scope(s) for external application. + +- `applicationScope` + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + - `folder_organization_unit` The Orchestrator folder (organization unit). diff --git a/docs/UiPathJobRun.md b/docs/UiPathJobRun.md index e2d4274..78bd534 100644 --- a/docs/UiPathJobRun.md +++ b/docs/UiPathJobRun.md @@ -3,15 +3,26 @@ Trigger a job on Orchestrator ```PowerShell SYNTAX - . 'C:\scripts\UiPathJobRun.ps1' -processName [-accountName -userKey ] [-folder_organization_unit ] - . 'C:\scripts\UiPathJobRun.ps1' -processName [-orchestrator_user -orchestrator_pass ] [-folder_organization_unit ] + . 'C:\scripts\UiPathJobRun.ps1' [-input_path ] [-jobscount ] [-result_path ] [-priority ] [-robots ] + [-fail_when_job_fails ] [-timeout ] [-wait ] [-orchestrator_user -orchestrator_pass ] [-userKey -accountName ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-language ] [-user ] [-machine ] [-job_type ] Example 1: -. 'C:\scripts\UiPathJobRun.ps1' -processName SimpleRPAFlow -uriOrch https://cloud.uipath.com -tenantlName AbdullahTenant -accountName accountLogicalName -userKey xxxxxxxxxx -folder_organization_unit folderName +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Low +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Normal -folder_organization_unit MyFolder +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority High -folder_organization_unit MyFolder +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -fail_when_job_fails false -timeout 0 +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority High -jobscount 3 -wait false -machine ROBOTMACHINE +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://cloud.uipath.com/" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority Low -robots robotName -result_path C:\Temp +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -robots robotName -result_path C:\Temp\status.json +. 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -accountForApp accountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -robots robotName -result_path C:\Temp\status.json + #Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') ``` +More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) + Script Parameters - `processName` orchestrator process name to run. @@ -34,6 +45,18 @@ Script Parameters - `accountName` Account logical name for Cloud Platform Orchestrator +- `accountForApp` + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +- `applicationId` + The external application id. Must be used together with account, secret and scope(s) for external application. + +- `applicationSecret` + The external application secret. Must be used together with account, id and scope(s) for external application. + +- `applicationScope` + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + - `input_path` Client ID for Cloud Platform Orchestrator diff --git a/docs/UiPathManageAssets.md b/docs/UiPathManageAssets.md index 23f83d3..0cd5a0f 100644 --- a/docs/UiPathManageAssets.md +++ b/docs/UiPathManageAssets.md @@ -5,31 +5,36 @@ Manage uipath orchestrator assets. - Deploy assets to an Orchestrator instance. ```PowerShell SYNTAX - . 'C:\scripts\UiPathManageAssets.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-language ] + . 'C:\scripts\UiPathManageAssets.ps1' [-accountForApp -applicationId -applicationSecret -applicationScope ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-language ] Examples (Deploy Assets): . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US + . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://cloud.uipath.com" defaultTenant -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -language en-US Examples (Delete Assets): . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US + . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://cloud.uipath.com" defaultTenant -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -language en-US + #Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') ``` +More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) + Script Parameters - `$operation` Manage assets operation either 'delete' or 'deploy' - `$assets_file` The following is a sample csv file. The column names are required! Only the first column is used but you need to at least have empty columns in place. -
name,type,value  
-        asset_1_name,boolean,false # we can have comments  
-        asset_2_name,integer,  
-        asset_3_name,text,  
-        asset_4_name,credential,username::password  
+        
name,type,value,description  
+        asset_1_name,text,asset_value # we can have comments,asset_1_description
+        asset_2_name,integer,123,asset_2_description
+        asset_3_name,boolean,false,asset_3_description
+        asset_4_name,credential,"username::password",asset_4_description
         
- `orchestrator_url` @@ -38,6 +43,18 @@ Script Parameters - `orchestrator_tenant` Required. The tenant of the Orchestrator instance. +- `accountForApp` + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +- `applicationId` + The external application id. Must be used together with account, secret and scope(s) for external application. + +- `applicationSecret` + The external application secret. Must be used together with account, id and scope(s) for external application. + +- `applicationScope` + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + - `orchestrator_user` Required. The Orchestrator username used for authentication. Must be used together with the password. diff --git a/docs/UiPathPack.md b/docs/UiPathPack.md index 844ee95..4a5797b 100644 --- a/docs/UiPathPack.md +++ b/docs/UiPathPack.md @@ -3,17 +3,20 @@ Pack one or more projects into a package. ```PowerShell SYNTAX - . 'C:\scripts\UiPathPack.ps1' -destination_folder [-version ] [-autoVersion] [-outputType ] [-libraryOrchestratorUrl -libraryOrchestratorTenant ] [-libraryOrchestratorUsername --libraryOrchestratorPassword ] [-libraryOrchestratorUserKey -libraryOrchestratorAccountName ] [-libraryOrchestratorFolder ] [-language ] + . 'C:\scripts\UiPathPack.ps1' -o [-version ] [-autoVersion] [-outputType ] [-libraryOrchestratorUrl -libraryOrchestratorTenant ] [-libraryOrchestratorUsername -libraryOrchestratorPassword ] [-libraryOrchestratorUserKey -libraryOrchestratorAccountName ] [-libraryOrchestratorAccountForApp -libraryOrchestratorApplicationId -libraryOrchestratorApplicationSecret -libraryOrchestratorApplicationScope ] + [-libraryOrchestratorFolder ] [-language ] Examples: - . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" + . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" --destination_folder "C:\UiPath\Package" . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -version 1.0.6820.22047 . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -autoVersion . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project" -destination_folder "C:\UiPath\Package" . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -outputType Tests -language en-US -#Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') +#Note: if the script folder location is different, you need to replace "C:" with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') ``` +More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) + Script Parameters - `project_path` Required. Path to a project.json file or a folder containing project.json files. @@ -39,6 +42,18 @@ Script Parameters - `libraryOrchestratorAccountName` (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. +- `libraryOrchestratorAccountForApp` + (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +- `libraryOrchestratorApplicationId` + (Optional, useful only for libraries) The external application id. Must be used together with account, secret and scope(s) for external application. + +- `libraryOrchestratorApplicationSecret` + (Optional, useful only for libraries) The external application secret. Must be used together with account, id and scope(s) for external application. + +- `libraryOrchestratorApplicationScope` + (Optional, useful only for libraries) The space-separated list of application scopes. Must be used together with account, id and secret for external application. + - `libraryOrchestratorFolder` (Optional, useful only for libraries) The Orchestrator folder (organization unit). diff --git a/docs/UiPathRunTest.md b/docs/UiPathRunTest.md index 4c2eaff..1b395fb 100644 --- a/docs/UiPathRunTest.md +++ b/docs/UiPathRunTest.md @@ -3,19 +3,23 @@ Tests a given package or runs a test set. ```PowerShell SYNTAX - . 'C:\scripts\UiPathRunTest.ps1' [-project_path ] [-testset ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-environment ] [-folder_organization_unit ] [-language ] + . 'C:\scripts\UiPathRunTest.ps1' [-input_path ] [-project_path ] [-testset ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-environment ] [-folder_organization_unit ] [-language ] Examples: - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -S "MyRobotTests" - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -environment TestingEnv - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder -environment MyEnvironment - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount -testset "MyRobotTests" - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -out junit - . 'C:\scripts\UiPathRunTest.ps1' "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -result_path "C:\results.json" -out uipath -language en-US + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -testset "MyRobotTests" + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -environment TestingEnv + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder -environment MyEnvironment + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -testset "MyRobotTests" + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -testset "MyRobotTests" + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv --out junit + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -result_path "C:\results.json" -out uipath -language en-US + . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -result_path "C:\results.json" -input_path "C:\UiPath\Project\input-params.json" -out uipath -language en-US #Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') ``` +More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) + Script Parameters - `project_path` The path to a test package file. @@ -32,6 +36,18 @@ Script Parameters - `result_path` Results file path +- `accountForApp` + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +- `applicationId` + The external application id. Must be used together with account, secret and scope(s) for external application. + +- `applicationSecret` + The external application secret. Must be used together with account, id and scope(s) for external application. + +- `applicationScope` + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + - `orchestrator_user` Required. The Orchestrator username used for authentication. Must be used together with the password. @@ -54,7 +70,7 @@ Script Parameters The time in seconds for waiting to finish test set executions. (default 7200) - `out` - Type of result file + Type of result file - `language` The orchestrator language. diff --git a/scripts/UiPathAnalyzeProject.ps1 b/scripts/UiPathAnalyzeProject.ps1 new file mode 100644 index 0000000..6ff92c0 --- /dev/null +++ b/scripts/UiPathAnalyzeProject.ps1 @@ -0,0 +1,266 @@ +<# +.SYNOPSIS + Check project(s) for workflow analyzer violations + +.DESCRIPTION + This script is used to analyze UiPath Studio Project for Warrning & Errors. + +.PARAMETER ProjectPath + Required. Path to a project.json file or a folder containing project.json files. + +.PARAMETER analyzerTraceLevel + Specifies what types of messages to output (Off|Error|Warning|Info|Verbose). + +.PARAMETER stopOnRuleViolation + Fail the job when any rule is violated. + +.PARAMETER treatWarningsAsErrors + Treat warnings as errors. + +.PARAMETER resultPath + The full path to a JSON file where the result json file will be created. Otherwise print it to the standard console. + +.PARAMETER ignoredRules + (Default: ) A comma-separated list of rules to be ignored by the analysis procedure. + +.PARAMETER orchestratorUsername + (Optional, useful only for additional package feeds) The Orchestrator username used for authentication. Must be used together with the password. + +.PARAMETER orchestratorPassword + (Optional, useful only for additional package feeds) The Orchestrator password used for authentication. Must be used together with the username. + +.PARAMETER orchestratorAuthToken + (Optional, useful only for additional package feeds) The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. + +.PARAMETER orchestratorAccountName + (Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. + +.PARAMETER orchestratorAccountForApp + (Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +.PARAMETER orchestratorApplicationId + (Optional, useful only for additional package feeds) The external application id. Must be used together with account, secret and scope(s) for external application. + +.PARAMETER orchestratorApplicationSecret + (Optional, useful only for additional package feeds) The external application secret. Must be used together with account, id and scope(s) for external application. + +.PARAMETER orchestratorApplicationScope + (Optional, useful only for additional package feeds) The space-separated list of application scopes. Must be used together with account, id and secret for external application. + +.PARAMETER orchestratorFolder + (Optional, useful only for additional package feeds) The Orchestrator folder (organization unit). + +.PARAMETER orchestratorUrl + (Optional, useful only for additional package feeds) The Orchestrator URL. + +.PARAMETER orchestratorTenant + (Optional, useful only for additional package feeds) The Orchestrator tenant. + +.EXAMPLE +SYNTAX + . '\UiPathAnalyzeProject.ps1' [-analyzerTraceLevel ] [-stopOnRuleViolation ] [-treatWarningsAsErrors ] [-saveOutputToFile] [-ignoredRules ] [-orchestratorUrl -orchestratorTenant ] [-orchestratorUsername -orchestratorPassword ] [-orchestratorAuthToken -orchestratorAccountName ] [-orchestratorFolder ] +Examples: + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" -ignoredRules "ST-NMG-009,ST-DBP-020,UI-USG-011,ST-DBP-020" + . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" -ignoredRules "ST-NMG-009,ST-DBP-020,UI-USG-011,ST-DBP-020" -orchestratorUrl "https://orchestratorurl.com" -orchestratorTenant "default" -orchestratorUsername "username" -orchestratorPassword "\_ye5zG9(x" -orchestratorAuthToken "AuthToken" -orchestratorAccountName "AccountName" -orchestratorFolder "OrchestratorFolder" + + #> + Param ( + + #Required + [string] $ProjectPath = "", # Required. Path to a project.json file or a folder containing project.json files. + [string] $analyzerTraceLevel = "", #Specifies what types of messages to output (Off|Error|Warning|Info|Verbose). + [string] $stopOnRuleViolation = "", #Fail the job when any rule is violated. + [string] $treatWarningsAsErrors = "", #Treat warnings as errors. + [string] $resultPath = "", #The full path to a JSON file where the result json file will be created. Otherwise print it to the standard console. + [string] $ignoredRules = "", #(Default: ) A comma-separated list of rules to be ignored by the analysis procedure. + [string] $orchestratorUsername = "", #(Optional, useful only for additional package feeds) The Orchestrator username used for authentication. Must be used together with the password. + [string] $orchestratorPassword = "", #(Optional, useful only for additional package feeds) The Orchestrator password used for authentication. Must be used together with the username. + [string] $orchestratorAuthToken = "", # (Optional, useful only for additional package feeds) The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. + [string] $orchestratorAccountName = "", #(Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. + [string] $orchestratorAccountForApp = "",#(Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + [string] $orchestratorApplicationId = "", #(Optional, useful only for additional package feeds) The external application id. Must be used together with account, secret and scope(s) for external application. + [string] $orchestratorApplicationSecret = "", #(Optional, useful only for additional package feeds) The external application secret. Must be used together with account, id and scope(s) for external application. + [string] $orchestratorApplicationScope = "", #(Optional, useful only for additional package feeds) The space-separated list of application scopes. Must be used together with account, id and secret for external application. + [string] $orchestratorFolder = "", #(Optional, useful only for additional package feeds) The Orchestrator folder (organization unit). + [string] $orchestratorUrl = "", #(Optional, useful only for additional package feeds) The Orchestrator URL. + [string] $orchestratorTenant = "" #(Optional, useful only for additional package feeds) The Orchestrator tenant. + + ) + #Log function + function WriteLog + { + Param ($message, [switch] $err) + + $now = Get-Date -Format "G" + $line = "$now`t$message" + $line | Add-Content $debugLog -Encoding UTF8 + if ($err) + { + Write-Host $line -ForegroundColor red + } else { + Write-Host $line + } + } + #Running Path + $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path + #log file + $debugLog = "$scriptPath\orchestrator-package-analyze.log" + + #Verifying UiPath CLI installation + $cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + + $uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" + if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { + WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." + try { + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" + if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { + WriteLog "Unable to locate uipath cli after it is downloaded." + exit 1 + } + } + catch { + WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception + exit 1 + } + + } + WriteLog "-----------------------------------------------------------------------------" + WriteLog "uipcli location : $uipathCLI" + #END Verifying UiPath CLI installation + + + $ParamList = New-Object 'Collections.Generic.List[string]' + + #region Verifying required paramteters + if($ProjectPath -eq "") + { + WriteLog "Fill the required paramters (packagesPath)" + exit 1 + } + + #endregion Verifying required paramteters + + #Building uipath cli paramters + $ParamList.Add("package") + $ParamList.Add("analyze") + $ParamList.Add($ProjectPath) + + + if($analyzerTraceLevel -ne ""){ + $ParamList.Add("--analyzerTraceLevel") + $ParamList.Add($analyzerTraceLevel) + } + if($stopOnRuleViolation -ne ""){ + if($stopOnRuleViolation.Trim().ToLower() -eq "true"){ + $ParamList.Add("--stopOnRuleViolation") + } + } + if($treatWarningsAsErrors -ne ""){ + if($treatWarningsAsErrors.Trim().ToLower() -eq "true"){ + $ParamList.Add("--treatWarningsAsErrors") + } + } + if($resultPath -ne ""){ + $ParamList.Add("--resultPath") + $ParamList.Add($resultPath) + } + if($ignoredRules -ne ""){ + $ParamList.Add("--ignoredRules") + $ParamList.Add("`"$ignoredRules`"") + } + if($orchestratorUsername -ne ""){ + $ParamList.Add("--orchestratorUsername") + $ParamList.Add($orchestratorUsername) + } + if($orchestratorPassword -ne ""){ + $ParamList.Add("--orchestratorPassword") + $ParamList.Add($orchestratorPassword) + } + if($orchestratorAuthToken -ne ""){ + $ParamList.Add("--orchestratorAuthToken") + $ParamList.Add($orchestratorAuthToken) + } + if($orchestratorAccountName -ne ""){ + $ParamList.Add("--orchestratorAccountName") + $ParamList.Add($orchestratorAccountName) + } + if($orchestratorAccountForApp -ne ""){ + $ParamList.Add("--orchestratorAccountForApp") + $ParamList.Add($orchestratorAccountForApp) + } + if($orchestratorApplicationId -ne ""){ + $ParamList.Add("--orchestratorApplicationId") + $ParamList.Add($orchestratorApplicationId) + } + if($orchestratorApplicationSecret -ne ""){ + $ParamList.Add("--orchestratorApplicationSecret") + $ParamList.Add($orchestratorApplicationSecret) + } + if($orchestratorApplicationScope -ne ""){ + $ParamList.Add("--orchestratorApplicationScope") + $ParamList.Add("`"$orchestratorApplicationScope`"") + } + if($orchestratorFolder -ne ""){ + $ParamList.Add("--orchestratorFolder") + $ParamList.Add($orchestratorFolder) + } + if($orchestratorUrl -ne ""){ + $ParamList.Add("--orchestratorUrl") + $ParamList.Add($orchestratorUrl) + } + if($orchestratorTenant -ne ""){ + $ParamList.Add("--orchestratorTenant") + $ParamList.Add($orchestratorTenant) + } + + + + + #mask sensitive info before logging + $ParamMask = New-Object 'Collections.Generic.List[string]' + $ParamMask.AddRange($ParamList) + $secretIndex = $ParamMask.IndexOf("--orchestratorPassword"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) + } + $secretIndex = $ParamMask.IndexOf("--orchestratorAuthToken"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = $orchestratorAuthToken.Substring(0, [Math]::Min($orchestratorAuthToken.Length, 4)) + ("*" * 15) + } + $secretIndex = $ParamMask.IndexOf("--orchestratorApplicationId"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = $orchestratorApplicationId.Substring(0, [Math]::Min($orchestratorApplicationId.Length, 4)) + ("*" * 15) + } + $secretIndex = $ParamMask.IndexOf("--orchestratorApplicationSecret"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) + } + + #log cli call with parameters + WriteLog "Executing $uipathCLI $ParamMask" + WriteLog "-----------------------------------------------------------------------------" + + #call uipath cli + & "$uipathCLI" $ParamList.ToArray() + + if($LASTEXITCODE -eq 0) + { + WriteLog "Done!" + Exit 0 + }else { + WriteLog "Analyzer returned errors or unable to analyze the project. Exit code $LASTEXITCODE" + Exit 1 + } + \ No newline at end of file diff --git a/scripts/UiPathCLIGeneric.ps1 b/scripts/UiPathCLIGeneric.ps1 new file mode 100644 index 0000000..113dbd4 --- /dev/null +++ b/scripts/UiPathCLIGeneric.ps1 @@ -0,0 +1,72 @@ +function WriteLog +{ + Param ($message, [switch] $err) + + $now = Get-Date -Format "G" + $line = "$now`t$message" + $line | Add-Content $debugLog -Encoding UTF8 + if ($err) + { + Write-Host $line -ForegroundColor red + } else { + Write-Host $line + } +} + +#Running Path +$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path +#log file +$debugLog = "$scriptPath\orchestrator-direct-cli-call.log" +#Verifying UiPath CLI installation +$cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + +$uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" +if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { + WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." + try { + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" + if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { + WriteLog "Unable to locate uipath cli after it is downloaded." + exit 1 + } + } + catch { + WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception + exit 1 + } + +} +WriteLog "-----------------------------------------------------------------------------" +WriteLog "uipcli location : $uipathCLI" +#END Verifying UiPath CLI installation + +$GenericParamList = New-Object 'Collections.Generic.List[string]' +for ( $i = 0; $i -lt $args.count; $i++ ) { + write-host "Argument $i is $($args[$i])" + if($args[$i].StartsWith("-")){ + $GenericParamList.Add($args[$i]) + } + else { + $GenericParamList.Add("`"$($args[$i])`"") + + } + +} +WriteLog "-----------------------------------------------------------------------------" +#call uipath cli +& "$uipathCLI" $GenericParamList.ToArray() + +if($LASTEXITCODE -eq 0) +{ + WriteLog "Done!" + Exit 0 +}else { + WriteLog "UiPath CLI returns error. Exit code $LASTEXITCODE" + Exit 1 +} \ No newline at end of file diff --git a/scripts/UiPathDeploy.ps1 b/scripts/UiPathDeploy.ps1 index 216ec8d..0a9e1cd 100644 --- a/scripts/UiPathDeploy.ps1 +++ b/scripts/UiPathDeploy.ps1 @@ -14,6 +14,18 @@ .PARAMETER orchestrator_tenant Required. The tenant of the Orchestrator instance. +.PARAMETER accountForApp + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +.PARAMETER applicationId + The external application id. Must be used together with account, secret and scope(s) for external application. + +.PARAMETER applicationSecret + The external application secret. Must be used together with account, id and scope(s) for external application. + +.PARAMETER applicationScope + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + .PARAMETER orchestrator_user Required. The Orchestrator username used for authentication. Must be used together with the password. @@ -32,6 +44,9 @@ .PARAMETER environment_list The comma-separated list of environments to deploy the package to. If the environment does not belong to the default folder (organization unit) it must be prefixed with the folder name, e.g. AccountingTeam\TestEnvironment +.PARAMETER entryPoints + Define the specific entry points to create or update a process. This is the filePath of the entry point starting from the root of the project. For classic folders only one entry point can be specified, for each environment it will be created or updated a process with the specified entry point. + .PARAMETER language The orchestrator language. @@ -40,12 +55,15 @@ .EXAMPLE SYNTAX - . '\UiPathDeploy.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-environment_list ] [-language ] -Examples: + . '\UiPathDeploy.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-environment_list ] [-language ] + + Examples: . '\UiPathDeploy.ps1' "C:\UiPath\Project 1" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 . '\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization - . '\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount . '\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -environment_list SAPEnvironment,ExcelAutomationEnvironment -language en-US + . '\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount + . '\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" + . '\UiPathDeploy.ps1' "C:\UiPath\Project\TestsPackage.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -environment_list SAPEnvironment,ExcelAutomationEnvironment -language en-US -entryPoints EntryPoint1,EntryPoint2 #> Param ( @@ -54,22 +72,31 @@ Param ( [string] $orchestrator_url = "", #Required. The URL of the Orchestrator instance. [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. - #cloud - Required + #External Apps (Option 1) + [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. + [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. + [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. + + #API Access - (Option 2) [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. - #On prem - Required + #On prem - (Option 3) [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). [string] $language = "", #The orchestrator language. [string] $environment_list = "", #The comma-separated list of environments to deploy the package to. If the environment does not belong to the default folder (organization unit) it must be prefixed with the folder name, e.g. AccountingTeam\TestEnvironment + [string] $entryPoints = "", #Define the specific entry points to create or update a process. This is the filePath of the entry point starting from the root of the project. For classic folders only one entry point can be specified, for each environment it will be created or updated a process with the specified entry point. [string] $disableTelemetry = "" #Disable telemetry data. + ) +#Log function function WriteLog { Param ($message, [switch] $err) @@ -84,18 +111,25 @@ function WriteLog Write-Host $line } } +#Running Path $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path +#log file $debugLog = "$scriptPath\orchestrator-package-deploy.log" -#Verifying UiPath CLI folder -$uipathCLI = "$scriptPath\uipathcli\lib\net461\uipcli.exe" +#Verifying UiPath CLI installation +$cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + +$uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." try { - New-Item -Path "$scriptPath" -ItemType "directory" -Name "uipathcli"; - Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/1.0.7802.11617" -OutFile "$scriptPath\\uipathcli\\cli.zip"; - Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\cli.zip" -DestinationPath "$scriptPath\\uipathcli"; - WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\\uipathcli" + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "Unable to locate uipath cli after it is downloaded." exit 1 @@ -109,24 +143,30 @@ if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { } WriteLog "-----------------------------------------------------------------------------" WriteLog "uipcli location : $uipathCLI" +#END Verifying UiPath CLI installation + $ParamList = New-Object 'Collections.Generic.List[string]' +#region Verifying required paramteters if($packages_path -eq "" -or $orchestrator_url -eq "" -or $orchestrator_tenant -eq "") { - WriteLog "Fill the required paramters" + WriteLog "Fill the required paramters (packages_path, orchestrator_url, orchestrator_tenant)" exit 1 } -if($account_name -eq "" -or $UserKey -eq "") +if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") { - if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + if($account_name -eq "" -or $UserKey -eq "") { - WriteLog "Fill the required paramters" - - exit 1 + if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + { + WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" + exit 1 + } } } +#endregion Verifying required paramteters #Building uipath cli paramters $ParamList.Add("package") @@ -135,56 +175,84 @@ $ParamList.Add($packages_path) $ParamList.Add($orchestrator_url) $ParamList.Add($orchestrator_tenant) +if($accountForApp -ne ""){ + $ParamList.Add("--accountForApp") + $ParamList.Add($accountForApp) +} +if($applicationId -ne ""){ + $ParamList.Add("--applicationId") + $ParamList.Add($applicationId) +} +if($applicationSecret -ne ""){ + $ParamList.Add("--applicationSecret") + $ParamList.Add($applicationSecret) +} +if($applicationScope -ne ""){ + $ParamList.Add("--applicationScope") + $ParamList.Add("`"$applicationScope`"") +} if($account_name -ne ""){ - $ParamList.Add("-a") + $ParamList.Add("--accountName") $ParamList.Add($account_name) } if($UserKey -ne ""){ - $ParamList.Add("-t") + $ParamList.Add("--token") $ParamList.Add($UserKey) - } if($orchestrator_user -ne ""){ - $ParamList.Add("-u") + $ParamList.Add("--username") $ParamList.Add($orchestrator_user) } if($orchestrator_pass -ne ""){ - $ParamList.Add("-p") + $ParamList.Add("--password") $ParamList.Add($orchestrator_pass) } if($folder_organization_unit -ne ""){ - $ParamList.Add("-o") + $ParamList.Add("--organizationUnit") $ParamList.Add($folder_organization_unit) } if($environment_list -ne ""){ - $ParamList.Add("-e") - $ParamList.Add($environment_list) + $ParamList.Add("--environments") + $ParamList.Add("`"$environment_list`"") } if($language -ne ""){ - $ParamList.Add("-l") + $ParamList.Add("--language") $ParamList.Add($language) } if($disableTelemetry -ne ""){ - $ParamList.Add("-y") + $ParamList.Add("--disableTelemetry") $ParamList.Add($disableTelemetry) } +if($entryPoints -ne ""){ + $ParamList.Add("--entryPointsPath") + $ParamList.Add($entryPoints) +} #mask sensitive info before logging $ParamMask = New-Object 'Collections.Generic.List[string]' $ParamMask.AddRange($ParamList) -$secretIndex = $ParamMask.IndexOf("-p"); +$secretIndex = $ParamMask.IndexOf("--password"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--token"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = ("*" * ($orchestrator_pass.Length)) + $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) } -$secretIndex = $ParamMask.IndexOf("-t"); +$secretIndex = $ParamMask.IndexOf("--applicationId"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = $userKey.Substring(0, 4) + ("*" * ($userKey.Length - 4)) + $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--applicationSecret"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) } #log cli call with parameters WriteLog "Executing $uipathCLI $ParamMask" +WriteLog "-----------------------------------------------------------------------------" #call uipath cli & "$uipathCLI" $ParamList.ToArray() diff --git a/scripts/UiPathJobRun.ps1 b/scripts/UiPathJobRun.ps1 index e13e144..ab29045 100644 --- a/scripts/UiPathJobRun.ps1 +++ b/scripts/UiPathJobRun.ps1 @@ -14,6 +14,18 @@ .PARAMETER tenantlName The tenant name +.PARAMETER accountForApp + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +.PARAMETER applicationId + The external application id. Must be used together with account, secret and scope(s) for external application. + +.PARAMETER applicationSecret + The external application secret. Must be used together with account, id and scope(s) for external application. + +.PARAMETER applicationScope + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + .PARAMETER orchestrator_user On-premises Orchestrator admin user name who has a Role of Create Package. @@ -68,16 +80,25 @@ .PARAMETER disableTelemetry Disable telemetry data. - -.EXAMPLE -PS> .\UiPathJobRun -processName SimpleRPAFlow -uriOrch https://cloud.uipath.com -tenantlName AbdullahTenant -accountName acountLogicalName -userKey uYxxxxxxxx -folder_organization_unit MyWork-Dev -- (Cloud Example) Run a process named SimpleRPAFlow in folder MyWork-Dev - .EXAMPLE -PS> .\UiPathJobRun -processName SimpleRPAFlow -uriOrch https://myorch.company.com -tenantlName AbdullahTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit MyWork-Dev -- (On Prem Example) Run a process named SimpleRPAFlow in folder MyWork-Dev - +SYNTAX: + .\UiPathJobRun.ps1 [-input_path ] [-jobscount ] [-result_path ] [-priority ] [-robots ] + [-fail_when_job_fails ] [-timeout ] [-wait ] [-orchestrator_user -orchestrator_pass ] [-userKey -accountName ] + [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-language ] [-user ] + [-machine ] [-job_type ] + Examples: + + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Low + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Normal -folder_organization_unit MyFolder + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority High -folder_organization_unit MyFolder + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -fail_when_job_fails false -timeout 0 + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority High -jobscount 3 -wait false -machine ROBOTMACHINE + .\UiPathJobRun.ps1 "ProcessName" "https://cloud.uipath.com/" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority Low -robots robotName -result_path C:\Temp + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -robots robotName -result_path C:\Temp\status.json + .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -accountForApp accountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -robots robotName -result_path C:\Temp\status.json + #> Param ( @@ -87,11 +108,17 @@ Param ( [string] $uriOrch = "", #Orchestrator URL (pos. 1) Required. The URL of the Orchestrator instance. [string] $tenantlName = "", #Orchestrator Tenant (pos. 2) Required. The tenant of the Orchestrator instance. - #cloud - Required + #External Apps (Option 1) + [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. + [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. + [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. + + #API Access - (Option 2) [string] $accountName = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. [string] $userKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. - #On prem - Required + #On prem UserName & Password - (Option 3) [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username. @@ -125,18 +152,25 @@ function WriteLog Write-Host $line } } +#Running Path $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path +#log file $debugLog = "$scriptPath\orchestrator-job-run.log" -#Verifying UiPath CLI folder -$uipathCLI = "$scriptPath\uipathcli\lib\net461\uipcli.exe" +#Verifying UiPath CLI installation +$cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + +$uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." try { - New-Item -Path "$scriptPath" -ItemType "directory" -Name "uipathcli"; - Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/1.0.7802.11617" -OutFile "$scriptPath\\uipathcli\\cli.zip"; - Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\cli.zip" -DestinationPath "$scriptPath\\uipathcli"; - WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\\uipathcli" + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "Unable to locate uipath cli after it is downloaded." exit 1 @@ -150,118 +184,148 @@ if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { } WriteLog "-----------------------------------------------------------------------------" WriteLog "uipcli location : $uipathCLI" +#END Verifying UiPath CLI installation $ParamList = New-Object 'Collections.Generic.List[string]' if($processName -eq "" -or $uriOrch -eq "" -or $tenantlName -eq "") { - WriteLog "Fill the required paramters" + WriteLog "Fill the required paramters (processName, uriOrch, tenantlName)" exit 1 } -if($accountName -eq "" -or $userKey -eq "") +if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") { - if($orchestrator_user -eq "" -or $orchestrator_user -eq "") + if($accountName -eq "" -or $userKey -eq "") { - WriteLog "Fill the required paramters" - - exit 1 + if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + { + WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" + exit 1 + } } } + #Building uipath cli paramters $ParamList.Add("job") $ParamList.Add("run") $ParamList.Add($processName) $ParamList.Add($uriOrch) $ParamList.Add($tenantlName) + +if($accountForApp -ne ""){ + $ParamList.Add("--accountForApp") + $ParamList.Add($accountForApp) +} +if($applicationId -ne ""){ + $ParamList.Add("--applicationId") + $ParamList.Add($applicationId) +} +if($applicationSecret -ne ""){ + $ParamList.Add("--applicationSecret") + $ParamList.Add($applicationSecret) +} +if($applicationScope -ne ""){ + $ParamList.Add("--applicationScope") + $ParamList.Add("`"$applicationScope`"") +} if($accountName -ne ""){ - $ParamList.Add("-a") + $ParamList.Add("--accountName") $ParamList.Add($accountName) } if($userKey -ne ""){ - $ParamList.Add("-t") + $ParamList.Add("--token") $ParamList.Add($userKey) } if($orchestrator_user -ne ""){ - $ParamList.Add("-u") + $ParamList.Add("--username") $ParamList.Add($orchestrator_user) } if($orchestrator_pass -ne ""){ - $ParamList.Add("-p") + $ParamList.Add("--password") $ParamList.Add($orchestrator_pass) } if($input_path -ne ""){ - $ParamList.Add("-i") + $ParamList.Add("--input_path") $ParamList.Add($input_path) } if($jobscount -ne ""){ - $ParamList.Add("-j") + $ParamList.Add("--jobscount") $ParamList.Add($jobscount) } if($result_path -ne ""){ - $ParamList.Add("-R") + $ParamList.Add("--result_path") $ParamList.Add($result_path) } if($priority -ne ""){ - $ParamList.Add("-P") + $ParamList.Add("--priority") $ParamList.Add($priority) } if($robots -ne ""){ - $ParamList.Add("-r") + $ParamList.Add("--robots") $ParamList.Add($robots) } if($folder_organization_unit -ne ""){ - $ParamList.Add("-o") + $ParamList.Add("--organizationUnit") $ParamList.Add($folder_organization_unit) } if($language -ne ""){ - $ParamList.Add("-l") + $ParamList.Add("--language") $ParamList.Add($language) } if($user -ne ""){ - $ParamList.Add("-U") + $ParamList.Add("--user") $ParamList.Add($user) } if($machine -ne ""){ - $ParamList.Add("-M") + $ParamList.Add("--machine") $ParamList.Add($machine) } if($timeout -ne ""){ - $ParamList.Add("-T") + $ParamList.Add("--timeout") $ParamList.Add($timeout) } if($fail_when_job_fails -ne ""){ - $ParamList.Add("-f") + $ParamList.Add("--fail_when_job_fails") $ParamList.Add($fail_when_job_fails) } if($wait -ne ""){ - $ParamList.Add("-w") + $ParamList.Add("--wait") $ParamList.Add($wait) } if($job_type -ne ""){ - $ParamList.Add("-b") + $ParamList.Add("--job_type") $ParamList.Add($job_type) } if($disableTelemetry -ne ""){ - $ParamList.Add("-y") + $ParamList.Add("--disableTelemetry") $ParamList.Add($disableTelemetry) } #mask sensitive info before logging $ParamMask = New-Object 'Collections.Generic.List[string]' $ParamMask.AddRange($ParamList) -$secretIndex = $ParamMask.IndexOf("-p"); +$secretIndex = $ParamMask.IndexOf("--password"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--token"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = ("*" * ($orchestrator_pass.Length)) + $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) } -$secretIndex = $ParamMask.IndexOf("-t"); +$secretIndex = $ParamMask.IndexOf("--applicationId"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = $userKey.Substring(0, 4) + ("*" * ($userKey.Length - 4)) + $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--applicationSecret"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) } #log cli call with parameters WriteLog "Executing $uipathCLI $ParamMask" +WriteLog "-----------------------------------------------------------------------------" #call uipath cli & "$uipathCLI" $ParamList.ToArray() diff --git a/scripts/UiPathManageAssets.ps1 b/scripts/UiPathManageAssets.ps1 index f8b1126..b41cb09 100644 --- a/scripts/UiPathManageAssets.ps1 +++ b/scripts/UiPathManageAssets.ps1 @@ -11,11 +11,10 @@ .PARAMETER $assets_file The following is a sample csv file. The column names are required! Only the first column is used but you need to at least have empty columns in place. - name,type,value - asset_1_name,boolean,false # we can have comments - asset_2_name,integer, - asset_3_name,text, - asset_4_name,credential,username::password + asset_1_name,text,asset_value # we can have comments,asset_1_description + asset_2_name,integer,123,asset_2_description + asset_3_name,boolean,false,asset_3_description + asset_4_name,credential,"username::password",asset_4_description .PARAMETER orchestrator_url Required. The URL of the Orchestrator instance. @@ -23,6 +22,17 @@ .PARAMETER orchestrator_tenant Required. The tenant of the Orchestrator instance. +.PARAMETER accountForApp + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +.PARAMETER applicationId + The external application id. Must be used together with account, secret and scope(s) for external application. + +.PARAMETER applicationSecret + The external application secret. Must be used together with account, id and scope(s) for external application. + +.PARAMETER applicationScope + The space-separated list of application scopes. Must be used together with account, id and secret for external application. .PARAMETER orchestrator_user Required. The Orchestrator username used for authentication. Must be used together with the password. @@ -48,183 +58,222 @@ .EXAMPLE SYNTAX - . 'C:\scripts\UiPathManageAssets.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-language ] + . 'C:\scripts\UiPathManageAssets.ps1' [-accountForApp -applicationId -applicationSecret -applicationScope ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-language ] Examples (Deploy Assets): . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US + . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://cloud.uipath.com" defaultTenant -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -language en-US Examples (Delete Assets): . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US + . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://cloud.uipath.com" defaultTenant -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -language en-US #> -Param ( - - #Required - [string] $operation = "", #Manage assets operation (delete | deploy) - [string] $assets_file = "", #Assets file - - [string] $orchestrator_url = "", #Required. The URL of the Orchestrator instance. - [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. - - #cloud - Required - [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. - [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. - - #On prem - Required - [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. - [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username - - [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). - [string] $language = "", #-l, --language The orchestrator language. - [string] $disableTelemetry = "", #-y, --disableTelemetry Disable telemetry data. - [string] $timeout = "" # The time in seconds for waiting to finish test set executions. (default 7200) - -) -function WriteLog -{ - Param ($message, [switch] $err) - - $now = Get-Date -Format "G" - $line = "$now`t$message" - $line | Add-Content $debugLog -Encoding UTF8 - if ($err) - { - Write-Host $line -ForegroundColor red - } else { - Write-Host $line - } -} -$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path -$debugLog = "$scriptPath\orchestrator-test-run.log" - - -#Verifying UiPath CLI folder -$uipathCLI = "$scriptPath\uipathcli\lib\net461\uipcli.exe" -if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { - WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." - try { - New-Item -Path "$scriptPath" -ItemType "directory" -Name "uipathcli"; - Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/1.0.7802.11617" -OutFile "$scriptPath\\uipathcli\\cli.zip"; - Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\cli.zip" -DestinationPath "$scriptPath\\uipathcli"; - WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\\uipathcli" - if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { - WriteLog "Unable to locate uipath cli after it is downloaded." + Param ( + + #Required + [string] $operation = "", #Manage assets operation (delete | deploy) + [string] $assets_file = "", #Assets file + + [string] $orchestrator_url = "", #Required. The URL of the Orchestrator instance. + [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. + + #External Apps (Option 1) + [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. + [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. + [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. + + #API Access - (Option 2) + [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. + [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. + + #On prem - (Option 3) + [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. + [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username + + [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). + [string] $language = "", #-l, --language The orchestrator language. + [string] $disableTelemetry = "", #-y, --disableTelemetry Disable telemetry data. + [string] $timeout = "" # The time in seconds for waiting to finish test set executions. (default 7200) + + ) + + function WriteLog + { + Param ($message, [switch] $err) + + $now = Get-Date -Format "G" + $line = "$now`t$message" + $line | Add-Content $debugLog -Encoding UTF8 + if ($err) + { + Write-Host $line -ForegroundColor red + } else { + Write-Host $line + } + } + #Running Path + $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path + #log file + $debugLog = "$scriptPath\orchestrator-test-run.log" + + #region Verifying UiPath CLI installation + $cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + + $uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" + if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { + WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." + try { + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" + if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { + WriteLog "Unable to locate uipath cli after it is downloaded." + exit 1 + } + } + catch { + WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception exit 1 } + } - catch { - WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception + WriteLog "-----------------------------------------------------------------------------" + WriteLog "uipcli location : $uipathCLI" + #endregion Verifying UiPath CLI installation + + $ParamList = New-Object 'Collections.Generic.List[string]' + + #region validate input paramters + if($operation -ne "delete" -and $operation -ne "deploy"){ + WriteLog "invalid operation. operation must either be 'delete' or 'deploy'. You typed '$operation'" exit 1 } -} -WriteLog "-----------------------------------------------------------------------------" -WriteLog "uipcli location : $uipathCLI" - -$ParamList = New-Object 'Collections.Generic.List[string]' - - -if($operation -ne "delete" -and $operation -ne "deploy"){ - WriteLog "invalid operation. operation must either be 'delete' or 'deploy'. You typed '$operation'" - exit 1 -} - -#full path of asset file -if(-not($assets_file.Contains("\"))) -{ - $assets_file = "$scriptPath\$assets_file" -} -if (-not(Test-Path -Path $assets_file -PathType Leaf)) { - WriteLog "asset file does not exist ($assets_file)" - exit 1 -} -if($orchestrator_url -eq "" -or $orchestrator_tenant -eq "") -{ - WriteLog "Fill the required paramters" - exit 1 -} - -#required parameters (Cloud accountName and userkey) or (on-prem username and password) -if($account_name -eq "" -or $UserKey -eq "") -{ - if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + #full path of asset file + if(-not($assets_file.Contains("\"))) { - WriteLog "Fill the required paramters" - + $assets_file = "$scriptPath\$assets_file" + } + if (-not(Test-Path -Path $assets_file -PathType Leaf)) { + WriteLog "assets file does not exist in ($assets_file)" + exit 1 + } + if($orchestrator_url -eq "" -or $orchestrator_tenant -eq "") + { + WriteLog "Fill the required paramters (orchestrator_url, orchestrator_tenant)" exit 1 } -} - -if($project_path -eq "" -and $testset -eq "") -{ - WriteLog "Either TestSet or Project path is required to fill" - exit 1 -} -#Building uipath cli paramters -$ParamList.Add("asset") -$ParamList.Add("$operation") -$ParamList.Add($assets_file) -$ParamList.Add($orchestrator_url) -$ParamList.Add($orchestrator_tenant) - -if($account_name -ne ""){ - $ParamList.Add("-a") - $ParamList.Add($account_name) -} -if($UserKey -ne ""){ - $ParamList.Add("-t") - $ParamList.Add($UserKey) -} -if($orchestrator_user -ne ""){ - $ParamList.Add("-u") - $ParamList.Add($orchestrator_user) -} -if($orchestrator_pass -ne ""){ - $ParamList.Add("-p") - $ParamList.Add($orchestrator_pass) -} -if($folder_organization_unit -ne ""){ - $ParamList.Add("-o") - $ParamList.Add($folder_organization_unit) -} -if($language -ne ""){ - $ParamList.Add("-l") - $ParamList.Add($language) -} - -if($disableTelemetry -ne ""){ - $ParamList.Add("-y") - $ParamList.Add($disableTelemetry) -} - - -#mask sensitive infos before loging -$ParamMask = New-Object 'Collections.Generic.List[string]' -$ParamMask.AddRange($ParamList) -$secretIndex = $ParamMask.IndexOf("-p"); -if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = ("*" * ($orchestrator_pass.Length)) -} -$secretIndex = $ParamMask.IndexOf("-t"); -if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = $userKey.Substring(0, 4) + ("*" * ($userKey.Length - 4)) -} - -#log cli call with parameters -WriteLog "Executing $uipathCLI $ParamMask" - -#call uipath cli -& "$uipathCLI" $ParamList.ToArray() - -if($LASTEXITCODE -eq 0) -{ - WriteLog "Done!" - Exit 0 -}else { - WriteLog "Unable to execute command. Exit code $LASTEXITCODE" - Exit 1 -} + + #required parameters (Cloud accountName and userkey) or (on-prem username and password) + if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") + { + if($account_name -eq "" -or $UserKey -eq "") + { + if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + { + WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" + exit 1 + } + } + } + #endregion validate input paramters + + + #region Building uipath cli paramters + $ParamList.Add("asset") + $ParamList.Add("$operation") + $ParamList.Add($assets_file) + $ParamList.Add($orchestrator_url) + $ParamList.Add($orchestrator_tenant) + + if($accountForApp -ne ""){ + $ParamList.Add("--accountForApp") + $ParamList.Add($accountForApp) + } + if($applicationId -ne ""){ + $ParamList.Add("--applicationId") + $ParamList.Add($applicationId) + } + if($applicationSecret -ne ""){ + $ParamList.Add("--applicationSecret") + $ParamList.Add($applicationSecret) + } + if($applicationScope -ne ""){ + $ParamList.Add("--applicationScope") + $ParamList.Add("`"$applicationScope`"") + } + if($account_name -ne ""){ + $ParamList.Add("--accountName") + $ParamList.Add($account_name) + } + if($UserKey -ne ""){ + $ParamList.Add("--token") + $ParamList.Add($UserKey) + } + if($orchestrator_user -ne ""){ + $ParamList.Add("--username") + $ParamList.Add($orchestrator_user) + } + if($orchestrator_pass -ne ""){ + $ParamList.Add("--password") + $ParamList.Add($orchestrator_pass) + } + if($folder_organization_unit -ne ""){ + $ParamList.Add("--organizationUnit") + $ParamList.Add($folder_organization_unit) + } + if($language -ne ""){ + $ParamList.Add("--language") + $ParamList.Add($language) + } + + if($disableTelemetry -ne ""){ + $ParamList.Add("--disableTelemetry") + $ParamList.Add($disableTelemetry) + } + #endregion Building uipath cli paramters + + #Mask sensitive infos before loging + $ParamMask = New-Object 'Collections.Generic.List[string]' + $ParamMask.AddRange($ParamList) + $secretIndex = $ParamMask.IndexOf("--password"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) + } + $secretIndex = $ParamMask.IndexOf("--token"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) + } + $secretIndex = $ParamMask.IndexOf("--applicationId"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) + } + $secretIndex = $ParamMask.IndexOf("--applicationSecret"); + if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) + } + #log cli call with parameters + WriteLog "Executing $uipathCLI $ParamMask" + + #call uipath cli + & "$uipathCLI" $ParamList.ToArray() + + if($LASTEXITCODE -eq 0) + { + WriteLog "Done!" + Exit 0 + }else { + WriteLog "Unable to execute command. Exit code $LASTEXITCODE" + Exit 1 + } + \ No newline at end of file diff --git a/scripts/UiPathPack.ps1 b/scripts/UiPathPack.ps1 index afffcf2..d0e4a1c 100644 --- a/scripts/UiPathPack.ps1 +++ b/scripts/UiPathPack.ps1 @@ -17,6 +17,18 @@ .PARAMETER libraryOrchestratorTenant (Optional, useful only for libraries) The Orchestrator tenant. +.PARAMETER libraryOrchestratorAccountForApp + (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +.PARAMETER libraryOrchestratorApplicationId + (Optional, useful only for libraries) The external application id. Must be used together with account, secret and scope(s) for external application. + +.PARAMETER libraryOrchestratorApplicationSecret + (Optional, useful only for libraries) The external application secret. Must be used together with account, id and scope(s) for external application. + +.PARAMETER libraryOrchestratorApplicationScope + (Optional, useful only for libraries) The space-separated list of application scopes. Must be used together with account, id and secret for external application. + .PARAMETER libraryOrchestratorUsername (Optional, useful only for libraries) The Orchestrator password used for authentication. Must be used together with the username. @@ -57,6 +69,16 @@ SYNTAX: package pack "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -autoVersion package pack "C:\UiPath\Project" -destination_folder "C:\UiPath\Package" package pack "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" --outputType Tests -language en-US + + .\UiPathPack.ps1 -o [-version ] [-autoVersion] [-outputType ] [-libraryOrchestratorUrl -libraryOrchestratorTenant ] [-libraryOrchestratorUsername -libraryOrchestratorPassword ] [-libraryOrchestratorUserKey -libraryOrchestratorAccountName ] [-libraryOrchestratorAccountForApp -libraryOrchestratorApplicationId -libraryOrchestratorApplicationSecret -libraryOrchestratorApplicationScope ] + [-libraryOrchestratorFolder ] [-language ] + + Examples: + .\UiPathPack.ps1 "C:\UiPath\Project\project.json" --destination_folder "C:\UiPath\Package" + .\UiPathPack.ps1 "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -version 1.0.6820.22047 + .\UiPathPack.ps1 "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -autoVersion + .\UiPathPack.ps1 "C:\UiPath\Project" -destination_folder "C:\UiPath\Package" + .\UiPathPack.ps1 "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -outputType Tests -language en-US #> Param ( @@ -67,13 +89,19 @@ Param ( [string] $libraryOrchestratorUrl = "", #Required. The URL of the Orchestrator instance. [string] $libraryOrchestratorTenant = "", #(Optional, useful only for libraries) The Orchestrator tenant. - #cloud - Required + #Extranal Apps (OAuth) (Cloud/OnPrem) + [string] $libraryOrchestratorAccountForApp = "", #(Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + [string] $libraryOrchestratorApplicationId = "", #(Optional, useful only for libraries) The external application id. Must be used together with account, secret and scope(s) for external application. + [string] $libraryOrchestratorApplicationSecret = "", #(Optional, useful only for libraries) The external application secret. Must be used together with account, id and scope(s) for external application. + [string] $libraryOrchestratorApplicationScope = "", #(Optional, useful only for libraries) The space-separated list of application scopes. Must be used together with account, id and secret for external application. + + #cloud API Access - Required [string] $libraryOrchestratorAccountName = "", #(Optional, useful only for libraries) The Orchestrator URL. [string] $libraryOrchestratorUserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. #On prem - Required - [string] $libraryOrchestratorUsername = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. - [string] $libraryOrchestratorPassword = "", #Required. The Orchestrator password used for authentication. Must be used together with the username. + [string] $libraryOrchestratorUsername = "", #Required. The Orchestrator username used for authentication. Must be used together with the libraryOrchestratorPassword. + [string] $libraryOrchestratorPassword = "", #Required. The Orchestrator password used for authentication. Must be used together with the libraryOrchestratorUsername. [string] $libraryOrchestratorFolder = "", #Optional, useful only for libraries) The Orchestrator folder (organization unit). [string] $language = "", #The orchestrator language. @@ -85,6 +113,7 @@ Param ( ) +#Log function function WriteLog { Param ($message, [switch] $err) @@ -99,18 +128,25 @@ function WriteLog Write-Host $line } } +#Running Path $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path +#log file $debugLog = "$scriptPath\orchestrator-package-pack.log" -#Verifying UiPath CLI folder -$uipathCLI = "$scriptPath\uipathcli\lib\net461\uipcli.exe" +#Verifying UiPath CLI installation +$cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + +$uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." try { - New-Item -Path "$scriptPath" -ItemType "directory" -Name "uipathcli"; - Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/1.0.7802.11617" -OutFile "$scriptPath\\uipathcli\\cli.zip"; - Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\cli.zip" -DestinationPath "$scriptPath\\uipathcli"; - WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\\uipathcli" + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "Unable to locate uipath cli after it is downloaded." exit 1 @@ -124,22 +160,22 @@ if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { } WriteLog "-----------------------------------------------------------------------------" WriteLog "uipcli location : $uipathCLI" +#END Verifying UiPath CLI installation + + +#Building uipath cli paramters $ParamList = New-Object 'Collections.Generic.List[string]' if($project_path -eq "" -or $destination_folder -eq "") { - WriteLog "Fill the required paramters" + WriteLog "Fill the required paramters (project_path, destination_folder)" exit 1 } - - - -#Building uipath cli paramters $ParamList.Add("package") $ParamList.Add("pack") $ParamList.Add($project_path) -$ParamList.Add("-o") +$ParamList.Add("--output") $ParamList.Add($destination_folder) if($libraryOrchestratorUrl -ne ""){ @@ -166,16 +202,32 @@ if($libraryOrchestratorPassword -ne ""){ $ParamList.Add("--libraryOrchestratorPassword") $ParamList.Add($libraryOrchestratorPassword) } +if($libraryOrchestratorAccountForApp -ne ""){ + $ParamList.Add("--libraryOrchestratorAccountForApp") + $ParamList.Add($libraryOrchestratorAccountForApp) +} +if($libraryOrchestratorApplicationId -ne ""){ + $ParamList.Add("--libraryOrchestratorApplicationId") + $ParamList.Add($libraryOrchestratorApplicationId) +} +if($libraryOrchestratorApplicationSecret -ne ""){ + $ParamList.Add("--libraryOrchestratorApplicationSecret") + $ParamList.Add($libraryOrchestratorApplicationSecret) +} +if($libraryOrchestratorApplicationScope -ne ""){ + $ParamList.Add("--libraryOrchestratorApplicationScope") + $ParamList.Add($libraryOrchestratorApplicationScope) +} if($libraryOrchestratorFolder -ne ""){ $ParamList.Add("--libraryOrchestratorFolder") $ParamList.Add($libraryOrchestratorFolder) } if($language -ne ""){ - $ParamList.Add("-l") + $ParamList.Add("--language") $ParamList.Add($language) } if($version -ne ""){ - $ParamList.Add("-v") + $ParamList.Add("--version") $ParamList.Add($version) } if($PSBoundParameters.ContainsKey('autoVersion')) { @@ -187,26 +239,35 @@ if($outputType -ne ""){ } if($disableTelemetry -ne ""){ - $ParamList.Add("-y") + $ParamList.Add("--disableTelemetry") $ParamList.Add($disableTelemetry) } -#mask sensitive info before logging +#region Mask sensitive info before logging $ParamMask = New-Object 'Collections.Generic.List[string]' $ParamMask.AddRange($ParamList) $secretIndex = $ParamMask.IndexOf("--libraryOrchestratorPassword"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = ("*" * ($libraryOrchestratorPassword.Length)) + $ParamMask[$secretIndex + 1] = ("*" * 15) } $secretIndex = $ParamMask.IndexOf("--libraryOrchestratorAuthToken"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = $userKey.Substring(0, 4) + ("*" * ($userKey.Length - 4)) + $ParamMask[$secretIndex + 1] = $libraryOrchestratorUserKey.Substring(0, [Math]::Min(4, $libraryOrchestratorUserKey.Length)) + ("*" * 15) } +$secretIndex = $ParamMask.IndexOf("--libraryOrchestratorApplicationId"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = $libraryOrchestratorApplicationId.Substring(0, [Math]::Min($libraryOrchestratorApplicationId.Length, 4)) + ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--libraryOrchestratorApplicationSecret"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) +} +#endregion Mask sensitive info before logging #log cli call with parameters WriteLog "Executing $uipathCLI $ParamMask" - +WriteLog "-----------------------------------------------------------------------------" #call uipath cli & "$uipathCLI" $ParamList.ToArray() diff --git a/scripts/UiPathRunTest.ps1 b/scripts/UiPathRunTest.ps1 index 1961362..d1662ac 100644 --- a/scripts/UiPathRunTest.ps1 +++ b/scripts/UiPathRunTest.ps1 @@ -20,6 +20,18 @@ .PARAMETER result_path Results file path +.PARAMETER accountForApp + The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + +.PARAMETER applicationId + The external application id. Must be used together with account, secret and scope(s) for external application. + +.PARAMETER applicationSecret + The external application secret. Must be used together with account, id and scope(s) for external application. + +.PARAMETER applicationScope + The space-separated list of application scopes. Must be used together with account, id and secret for external application. + .PARAMETER orchestrator_user Required. The Orchestrator username used for authentication. Must be used together with the password. @@ -52,16 +64,19 @@ .EXAMPLE -.\UiPathRunTest.ps1 [-project_path ] [-testset ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-environment ] [-folder_organization_unit ] [-language ] +SYNTAX + .\UiPathRunTest.ps1 [-input_path ] [-project_path ] [-testset ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-environment ] [-folder_organization_unit ] [-language ] Examples: - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -S "MyRobotTests" - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -environment TestingEnv - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder -environment MyEnvironment - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount -testset "MyRobotTests" - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -out junit - .\UiPathRunTest.ps1 "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -result_path "C:\results.json" -out uipath -language en-US + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -testset "MyRobotTests" + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -environment TestingEnv + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -project_path "C:\UiPath\Project\project.json" -folder_organization_unit MyFolder -environment MyEnvironment + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -accountForApp myAccountForExternalApp -applicationId myExternalAppId -applicationSecret myExternalAppSecret -applicationScope "OR.Folders.Read OR.Settings.Read" -testset "MyRobotTests" + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -testset "MyRobotTests" + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv --out junit + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -result_path "C:\results.json" -out uipath -language en-US + .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -project_path "C:\UiPath\Project\project.json" -environment TestingEnv -result_path "C:\results.json" -input_path "C:\UiPath\Project\input-params.json" -out uipath -language en-US #> Param ( @@ -70,11 +85,18 @@ Param ( [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. [string] $project_path = "", #The path to a test package file. + [string] $input_path = "", #The full path to a JSON input file. Only required if the entry-point workflow has input parameters and you want to pass them from command line. [string] $testset = "", #The name of the test set to execute. The test set should use the latest version of the test cases. If the test set does not belong to the default folder (organization unit) it must be prefixed with the folder name, e.g. AccountingTeam\TestSet [string] $result_path = "", #Results file path - #cloud - Required + #External Apps (Option 1) + [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. + [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. + [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. + [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. + + #API Access - (Option 2) [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. @@ -87,7 +109,8 @@ Param ( [string] $environment = "", #The environment to deploy the package to. Must be used together with the project path. Required when not using a modern folder. [string] $disableTelemetry = "", #-y, --disableTelemetry Disable telemetry data. [string] $timeout = "", # The time in seconds for waiting to finish test set executions. (default 7200) - [string] $out = "" #Type of result file + [string] $out = "", #Type of result file + [string] $traceLevel = "" ) function WriteLog { @@ -103,18 +126,25 @@ function WriteLog Write-Host $line } } +#Running Path $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path +#log file $debugLog = "$scriptPath\orchestrator-test-run.log" -#Verifying UiPath CLI folder -$uipathCLI = "$scriptPath\uipathcli\lib\net461\uipcli.exe" +#Verifying UiPath CLI installation +$cliVersion = "1.0.7985.19721"; #CLI Version (Script was tested on this latest version at the time) + +$uipathCLI = "$scriptPath\uipathcli\$cliVersion\lib\net461\uipcli.exe" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." try { - New-Item -Path "$scriptPath" -ItemType "directory" -Name "uipathcli"; - Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/1.0.7802.11617" -OutFile "$scriptPath\\uipathcli\\cli.zip"; - Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\cli.zip" -DestinationPath "$scriptPath\\uipathcli"; - WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\\uipathcli" + if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ + New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null + } + #Download UiPath CLI + Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; + Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; + WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { WriteLog "Unable to locate uipath cli after it is downloaded." exit 1 @@ -128,26 +158,29 @@ if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { } WriteLog "-----------------------------------------------------------------------------" WriteLog "uipcli location : $uipathCLI" +#END Verifying UiPath CLI installation + $ParamList = New-Object 'Collections.Generic.List[string]' if($orchestrator_url -eq "" -or $orchestrator_tenant -eq "") { - WriteLog "Fill the required paramters" + WriteLog "Fill the required paramters (orchestrator_url, orchestrator_tenant)" exit 1 } -#required parameters (Cloud accountName and userkey) or (on-prem username and password) -if($account_name -eq "" -or $UserKey -eq "") +#required parameters (Authintication) +if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") { - if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + if($account_name -eq "" -or $userKey -eq "") { - WriteLog "Fill the required paramters" - - exit 1 + if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") + { + WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" + exit 1 + } } } - if($project_path -eq "" -and $testset -eq "") { WriteLog "Either TestSet or Project path is required to fill" @@ -160,44 +193,63 @@ $ParamList.Add($orchestrator_url) $ParamList.Add($orchestrator_tenant) if($project_path -ne ""){ - $ParamList.Add("-P") + $ParamList.Add("--project-path") $ParamList.Add($project_path) } +if($input_path -ne ""){ + $ParamList.Add("--input_path") + $ParamList.Add($input_path) +} if($testset -ne ""){ - $ParamList.Add("-s") + $ParamList.Add("--testset") $ParamList.Add($testset) } if($result_path -ne ""){ - $ParamList.Add("-r") + $ParamList.Add("--result_path") $ParamList.Add($result_path) } - +if($accountForApp -ne ""){ + $ParamList.Add("--accountForApp") + $ParamList.Add($accountForApp) +} +if($applicationId -ne ""){ + $ParamList.Add("--applicationId") + $ParamList.Add($applicationId) +} +if($applicationSecret -ne ""){ + $ParamList.Add("--applicationSecret") + $ParamList.Add($applicationSecret) +} +if($applicationScope -ne ""){ + $ParamList.Add("--applicationScope") + $ParamList.Add("`"$applicationScope`"") +} if($account_name -ne ""){ - $ParamList.Add("-a") + $ParamList.Add("--accountName") $ParamList.Add($account_name) } if($UserKey -ne ""){ - $ParamList.Add("-t") + $ParamList.Add("--token") $ParamList.Add($UserKey) } if($orchestrator_user -ne ""){ - $ParamList.Add("-u") + $ParamList.Add("--username") $ParamList.Add($orchestrator_user) } if($orchestrator_pass -ne ""){ - $ParamList.Add("-p") + $ParamList.Add("--password") $ParamList.Add($orchestrator_pass) } if($folder_organization_unit -ne ""){ - $ParamList.Add("-o") + $ParamList.Add("--organizationUnit") $ParamList.Add($folder_organization_unit) } if($environment -ne ""){ - $ParamList.Add("-e") + $ParamList.Add("--environment") $ParamList.Add($environment) } if($timeout -ne ""){ - $ParamList.Add("-w") + $ParamList.Add("--timeout") $ParamList.Add($timeout) } if($out -ne ""){ @@ -205,12 +257,15 @@ if($out -ne ""){ $ParamList.Add($out) } if($language -ne ""){ - $ParamList.Add("-l") + $ParamList.Add("-language") $ParamList.Add($language) } - +if($traceLevel -ne ""){ + $ParamList.Add("--traceLevel") + $ParamList.Add($traceLevel) +} if($disableTelemetry -ne ""){ - $ParamList.Add("-y") + $ParamList.Add("--disableTelemetry") $ParamList.Add($disableTelemetry) } @@ -218,13 +273,22 @@ if($disableTelemetry -ne ""){ #mask sensitive infos before loging $ParamMask = New-Object 'Collections.Generic.List[string]' $ParamMask.AddRange($ParamList) -$secretIndex = $ParamMask.IndexOf("-p"); + +$secretIndex = $ParamMask.IndexOf("--password"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--token"); +if($secretIndex -ge 0){ + $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) +} +$secretIndex = $ParamMask.IndexOf("--applicationId"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = ("*" * ($orchestrator_pass.Length)) + $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) } -$secretIndex = $ParamMask.IndexOf("-t"); +$secretIndex = $ParamMask.IndexOf("--applicationSecret"); if($secretIndex -ge 0){ - $ParamMask[$secretIndex + 1] = $userKey.Substring(0, 4) + ("*" * ($userKey.Length - 4)) + $ParamMask[$secretIndex + 1] = ("*" * 15) } #log cli call with parameters