├── .gitignore ├── docs ├── UiPathAuthenticationsOptions.md ├── UiPathCLIGeneric.md ├── UiPathPack.md ├── UiPathDeploy.md ├── UiPathManageAssets.md ├── UiPathAnalyzeProject.md ├── UiPathJobRun.md └── UiPathRunTest.md ├── yaml_samples ├── gitlab_sample.yml └── circleci_sample.yml ├── scripts ├── UiPathCLIGeneric.ps1 ├── UiPathDeploy.ps1 ├── UiPathPack.ps1 ├── UiPathManageAssets.ps1 ├── UiPathAnalyzeProject.ps1 ├── UiPathJobRun.ps1 └── UiPathRunTest.ps1 └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | scripts/test.ps1 2 | scripts/uipathcli/* 3 | test_scripts/* 4 | *.csv 5 | *.log 6 | .vscode/* 7 | -------------------------------------------------------------------------------- /docs/UiPathAuthenticationsOptions.md: -------------------------------------------------------------------------------- 1 | ## Authentication Options 2 | | Authentication Option | How To | 3 | | ------------- | ------------- | 4 | | 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 | 5 | | 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 | 6 | | Username&Password | on-prem orchestrator username & password | -------------------------------------------------------------------------------- /docs/UiPathCLIGeneric.md: -------------------------------------------------------------------------------- 1 | # UiPathCLIGeneric 2 | 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. 3 | ```PowerShell 4 | SYNTAX 5 | . 'C:\scripts\UiPathCLIGeneric.ps1' 6 | 7 | Examples: 8 | . 'C:\scripts\UiPathCLIGeneric.ps1' package pack "C:\UiPath\Project\project.json" -o "C:\UiPath\Package" 9 | . 'C:\scripts\UiPathCLIGeneric.ps1' job run ProcessName "https://uipath-orchestrator.myorg.com" default -u admin -p 123456 10 | . 'C:\scripts\UiPathCLIGeneric.ps1' robot connect machine-name "https://uipath-orchestrator.myorg.com" default -u admin -p 123456 -o OurOrganization -l en-US 11 | . 'C:\scripts\UiPathCLIGeneric.ps1' machine provision MachineNameExample Template "https://uipath-orchestrator.myorg.com" default -u admin -p 123456 -o ModernFolder -l en-US 12 | . 'C:\scripts\UiPathCLIGeneric.ps1'app install Studio -m UiPathStudio.msi 13 | 14 | #Note: if the script folder location is different, you need to replace "C:" with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 15 | ``` 16 | -------------------------------------------------------------------------------- /yaml_samples/gitlab_sample.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - pack 3 | - test 4 | - deploy 5 | 6 | # - PreTest 7 | # - Build_Package 8 | # - Deploy_to_Dev 9 | # - UAT_Test 10 | # - Deploy_To_Prod 11 | Pack Project: 12 | stage: pack 13 | 14 | # There is no image: tag because Windows shared runners are shell runners 15 | # These tags are only required for targeting shared Windows runners on GitLab.com, remove for self-hosted private runners 16 | before_script: 17 | - Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathPack.ps1" -OutFile "$env:CI_PROJECT_DIR\UiPathPack.ps1"; 18 | 19 | script: 20 | - | 21 | Write-Host $env:CI_PROJECT_DIR 22 | New-Item -Path "$env:CI_PROJECT_DIR\\" -ItemType "directory" -Name "output_packages"; 23 | . "$env:CI_PROJECT_DIR\UiPathPack.ps1" "$env:CI_PROJECT_DIR\project.json" "$env:CI_PROJECT_DIR\output_packages\" -autoVersion 24 | 25 | artifacts: 26 | paths: [ "$env:CI_PROJECT_DIR\\output_packages\\" ] 27 | expire_in: 30 days 28 | 29 | Test Package: 30 | stage: test 31 | 32 | before_script: 33 | - Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathRunTest.ps1" -OutFile "$env:CI_PROJECT_DIR\UiPathRunTest.ps1"; 34 | 35 | script: 36 | - . "$env:CI_PROJECT_DIR\UiPathRunTest.ps1" "http://cloud.uipath.com" AbdullahTenant -userKey $env:uipathUserKey -account_name $env:uipathAccountName -project_path "$env:CI_PROJECT_DIR\project.json" -result_path "$env:CI_PROJECT_DIR\junit_package_test_result.xml" -out junit -folder_organization_unit DevWork 37 | artifacts: 38 | paths: [ "$env:CI_PROJECT_DIR\\output_results\\" ] 39 | reports: 40 | junit: junit_package_test_result.xml 41 | 42 | Run Testset: 43 | stage: test 44 | 45 | before_script: 46 | - Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathRunTest.ps1" -OutFile "$env:CI_PROJECT_DIR\UiPathRunTest.ps1"; 47 | 48 | script: 49 | - . "$env:CI_PROJECT_DIR\UiPathRunTest.ps1" "http://cloud.uipath.com" AbdullahTenant -userKey $env:uipathUserKey -account_name $env:uipathAccountName -testset "CircleCI-TestSet" -result_path "$env:CI_PROJECT_DIR\output_results\junit_testset_result.xml" -out junit -folder_organization_unit DevWork 50 | artifacts: 51 | paths: [ "$env:CI_PROJECT_DIR\\output_results\\" ] 52 | reports: 53 | junit: junit_testset_result.xml 54 | 55 | Deploy Package: 56 | stage: deploy 57 | 58 | before_script: 59 | - Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathDeploy.ps1" -OutFile "$env:CI_PROJECT_DIR\UiPathDeploy.ps1"; 60 | 61 | script: 62 | - . "$env:CI_PROJECT_DIR\UiPathDeploy.ps1" "$env:CI_PROJECT_DIR\\output_packages\\" "http://cloud.uipath.com" "AbdullahTenant" -account_name $env:uipathAccountName -userKey $env:uipathUserKey -folder_organization_unit DevWork 63 | 64 | Deploy Assets: 65 | stage: deploy 66 | 67 | before_script: 68 | - Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathManageAssets.ps1" -OutFile "$env:CI_PROJECT_DIR\UiPathManageAssets.ps1"; 69 | 70 | script: 71 | - . "$env:CI_PROJECT_DIR\UiPathManageAssets.ps1" deploy "$env:CI_PROJECT_DIR\assets\assets_to_deploy.csv" "https://cloud.uipath.com" AbdullahTenant -UserKey $env:uipathUserKey -account_name $env:uipathAccountName -folder_organization_unit DevWork -language en-US 72 | 73 | 74 | -------------------------------------------------------------------------------- /yaml_samples/circleci_sample.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | win: circleci/windows@2.2.0 5 | 6 | jobs: 7 | build: 8 | working_directory: C:\workingdir\ 9 | executor: 10 | name: win/default 11 | shell: powershell.exe 12 | steps: 13 | - checkout 14 | - run: 15 | name: "Download PS Scripts" 16 | command: | 17 | New-Item -Path "C:\\" -ItemType "directory" -Name "scripts"; 18 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathPack.ps1" -OutFile "C:\\scripts\\UiPathPack.ps1"; 19 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathDeploy.ps1" -OutFile "C:\\scripts\\UiPathDeploy.ps1"; 20 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathJobRun.ps1" -OutFile "C:\\scripts\\UiPathJobRun.ps1"; 21 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathRunTest.ps1" -OutFile "C:\\scripts\\UiPathRunTest.ps1"; 22 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathManageAssets.ps1" -OutFile "C:\\scripts\\UiPathManageAssets.ps1"; 23 | # UiPath Pack 24 | - run: 25 | name: "UiPath Pack" 26 | command: | 27 | New-Item -Path "C:\\workingdir\\" -ItemType "directory" -Name "output"; 28 | . 'C:\scripts\UiPathPack.ps1' "C:\workingdir\project.json" "C:\\workingdir\\output\\" -autoVersion 29 | # UiPath Test Run 30 | - run: 31 | name: "UiPath Run Test cases in the project" 32 | command: 33 | . 'C:\scripts\UiPathRunTest.ps1' "http://cloud.uipath.com" AbdullahTenant -userKey $env:uipathUserKey -account_name $env:uipathAccountName -project_path "C:\workingdir\project.json" -result_path "C:\workingdir\output_results\junit_rpa_test_result.xml" -out junit -folder_organization_unit DevWork 34 | - run: 35 | name: "UiPath Run Testsets in orchestrator" 36 | command: 37 | . 'C:\scripts\UiPathRunTest.ps1' "http://cloud.uipath.com" AbdullahTenant -userKey $env:uipathUserKey -account_name $env:uipathAccountName -testset "CircleCI-TestSet" -result_path "C:\workingdir\output_results\junit_rpa_testset_result.xml" -out junit -folder_organization_unit DevWork 38 | - store_test_results: 39 | path: "C:\\workingdir\\output_results" 40 | 41 | # UiPath Deploy 42 | - run: 43 | name: "Deploy Project" 44 | shell: powershell.exe 45 | command: 46 | . 'C:\scripts\UiPathDeploy.ps1' "C:\\workingdir\\output\\" "http://cloud.uipath.com" "AbdullahTenant" -account_name $env:uipathAccountName -userKey $env:uipathUserKey -folder_organization_unit DevWork 47 | 48 | # UiPath Run process 49 | - run: 50 | name: "Run Process" 51 | shell: powershell.exe 52 | command: 53 | . 'C:\scripts\UiPathJobRun.ps1' -processName SimpleRPAFlow -uriOrch https://cloud.uipath.com -tenantlName AbdullahTenant -accountName $env:uipathAccountName -userKey $env:uipathUserKey -folder_organization_unit MyWork-Dev -wait false 54 | 55 | # UiPath Manage Asset 56 | - run: 57 | name: "Deploy Assets" 58 | shell: powershell.exe 59 | command: 60 | . 'C:\scripts\UiPathManageAssets.ps1' deploy "C:\workingdir\assets\assets_to_deploy.csv" "https://cloud.uipath.com" AbdullahTenant -UserKey $env:uipathUserKey -account_name $env:uipathAccountName -folder_organization_unit DevWork -language en-US 61 | - run: 62 | name: "Delete Assets" 63 | shell: powershell.exe 64 | command: | 65 | . 'C:\scripts\UiPathManageAssets.ps1' delete "C:\workingdir\assets\assets_to_delete.csv" "https://cloud.uipath.com" AbdullahTenant -UserKey $env:uipathUserKey -account_name $env:uipathAccountName -folder_organization_unit DevWork -language en-US 66 | -------------------------------------------------------------------------------- /scripts/UiPathCLIGeneric.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | call uipcli.exe with cli paramters 4 | 5 | .DESCRIPTION 6 | call uipcli.exe with cli paramters 7 | 8 | # .PARAMETER uipathCliFilePath 9 | # if not provided, the script will auto download the cli from uipath public feed. 10 | #> 11 | # Param ( 12 | # [string] $uipathCliFilePath = "" #if not provided, the script will auto download the cli from uipath public feed. 13 | # ) 14 | function WriteLog 15 | { 16 | Param ($message, [switch] $err) 17 | 18 | $now = Get-Date -Format "G" 19 | $line = "$now`t$message" 20 | $line | Add-Content $debugLog -Encoding UTF8 21 | if ($err) 22 | { 23 | Write-Host $line -ForegroundColor red 24 | } else { 25 | Write-Host $line 26 | } 27 | } 28 | 29 | #Running Path 30 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 31 | #log file 32 | $debugLog = "$scriptPath\orchestrator-direct-cli-call.log" 33 | 34 | $uipathCliFilePath = "" #provide uipcli.exe if running on self-hosted agent and uipath cli is available on the machine 35 | #Validate provided cli folder (if any) 36 | if($uipathCliFilePath -ne ""){ 37 | $uipathCLI = "$uipathCliFilePath" 38 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 39 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 40 | exit 1 41 | } 42 | }else{ 43 | #Verifying UiPath CLI installation 44 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 45 | 46 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 47 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 48 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 49 | try { 50 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 51 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 52 | } 53 | #Download UiPath CLI 54 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 55 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 56 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 57 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 58 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 59 | WriteLog "Unable to locate uipath cli after it is downloaded." 60 | exit 1 61 | } 62 | } 63 | catch { 64 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 65 | exit 1 66 | } 67 | 68 | } 69 | } 70 | WriteLog "-----------------------------------------------------------------------------" 71 | WriteLog "uipcli location : $uipathCLI" 72 | #END Verifying UiPath CLI installation 73 | 74 | $GenericParamList = New-Object 'Collections.Generic.List[string]' 75 | for ( $i = 0; $i -lt $args.count; $i++ ) { 76 | #write-host "Argument $i is $($args[$i])" 77 | if($args[$i].StartsWith("-")){ 78 | $GenericParamList.Add($args[$i]) 79 | } 80 | else { 81 | $GenericParamList.Add("`"$($args[$i])`"") 82 | } 83 | 84 | } 85 | WriteLog "-----------------------------------------------------------------------------" 86 | #call uipath cli 87 | & "$uipathCLI" $GenericParamList.ToArray() 88 | 89 | if($LASTEXITCODE -eq 0) 90 | { 91 | WriteLog "Done!" 92 | Exit 0 93 | }else { 94 | WriteLog "UiPath CLI returns error. Exit code $LASTEXITCODE" 95 | Exit 1 96 | } -------------------------------------------------------------------------------- /docs/UiPathPack.md: -------------------------------------------------------------------------------- 1 | 2 | # UiPathPack 3 | Pack one or more projects into a package. 4 | ```PowerShell 5 | SYNTAX 6 | . 'C:\scripts\UiPathPack.ps1' -o [-version ] [-autoVersion] [-outputType ] [-libraryOrchestratorUrl -libraryOrchestratorTenant ] [-libraryOrchestratorUsername -libraryOrchestratorPassword ] [-libraryOrchestratorUserKey -libraryOrchestratorAccountName ] [-libraryOrchestratorAccountForApp -libraryOrchestratorApplicationId -libraryOrchestratorApplicationSecret -libraryOrchestratorApplicationScope ] 7 | [-libraryOrchestratorFolder ] [-language ] [-uipathCliFilePath ] 8 | 9 | Examples: 10 | . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" 11 | . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -version 1.0.6820.22047 12 | . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -autoVersion 13 | . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project" -destination_folder "C:\UiPath\Package" 14 | . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -outputType Tests -language en-US 15 | 16 | #Note: if the script folder location is different, you need to replace "C:" with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 17 | ``` 18 | if running on self-hosted agent and UiPath CLI is available on the agent machine, provide `-uipathCliFilePath` 19 | ```PowerShell 20 | Examples: 21 | . 'C:\scripts\UiPathPack.ps1' "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -uipathCliFilePath "C:\uipathcli\uipcli.exe" 22 | ``` 23 | More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) 24 | 25 | Script Parameters 26 | 27 | - `project_path` 28 | Required. Path to a project.json file or a folder containing project.json files. 29 | 30 | - `destination_folder` 31 | Required. Destination folder. 32 | 33 | - `libraryOrchestratorUrl` 34 | (Optional, useful only for libraries) The Orchestrator URL. 35 | 36 | - `libraryOrchestratorTenant` 37 | (Optional, useful only for libraries) The Orchestrator tenant. 38 | 39 | - `libraryOrchestratorUsername` 40 | (Optional, useful only for libraries) The Orchestrator password used for authentication. Must be used together with the username. 41 | 42 | - `libraryOrchestratorPassword` 43 | (Optional, useful only for libraries) The Orchestrator username used for authentication. Must be used together with the password. 44 | 45 | - `libraryOrchestratorUserKey` 46 | (Optional, useful only for libraries) The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 47 | 48 | - `libraryOrchestratorAccountName` 49 | (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 50 | 51 | - `libraryOrchestratorAccountForApp` 52 | (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 53 | 54 | - `libraryOrchestratorApplicationId` 55 | (Optional, useful only for libraries) The external application id. Must be used together with account, secret and scope(s) for external application. 56 | 57 | - `libraryOrchestratorApplicationSecret` 58 | (Optional, useful only for libraries) The external application secret. Must be used together with account, id and scope(s) for external application. 59 | 60 | - `libraryOrchestratorApplicationScope` 61 | (Optional, useful only for libraries) The space-separated list of application scopes. Must be used together with account, id and secret for external application. 62 | 63 | - `libraryOrchestratorFolder` 64 | (Optional, useful only for libraries) The Orchestrator folder (organization unit). 65 | 66 | - `version` 67 | Package version. 68 | 69 | - `autoVersion` 70 | Auto-generate package version. 71 | 72 | - `outputType` 73 | Force the output to a specific type. 74 | 75 | - `language` 76 | The orchestrator language. 77 | 78 | - `disableTelemetry` 79 | Disable telemetry data. 80 | 81 | - `uipathCliFilePath` 82 | if not provided, the script will auto download the cli from uipath public feed. the script was tested on version 23.10.8753.32995 83 | 84 | - `SpecificCLIVersion` 85 | CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested. -------------------------------------------------------------------------------- /docs/UiPathDeploy.md: -------------------------------------------------------------------------------- 1 | 2 | # UiPathDeploy 3 | Deploy packages to an Orchestrator instance, optionally publishing them to a set of environments. 4 | ```PowerShell 5 | SYNTAX 6 | . 'C:\scripts\\UiPathDeploy.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-entryPoints Main.xaml][-environment_list ] [-language ] [-uipathCliFilePath ] 7 | Examples: 8 | . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project 1" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 9 | . '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 10 | . '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 11 | . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount 12 | . '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" 13 | . '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 14 | 15 | #Note: if script path is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 16 | ``` 17 | if running on self-hosted agent and UiPath CLI is available on the agent machine, provide `-uipathCliFilePath` 18 | ```PowerShell 19 | Examples: 20 | . 'C:\scripts\UiPathDeploy.ps1' "C:\UiPath\Project 1" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -uipathCliFilePath "C:\uipathcli\uipcli.exe" 21 | ``` 22 | 23 | More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) 24 | 25 | Script Parameters 26 | - `packages_path` 27 | Required. The path to a folder containing packages, or to a package file. 28 | 29 | - `orchestrator_url` 30 | Required. The URL of the Orchestrator instance. 31 | 32 | - `orchestrator_tenant` 33 | Required. The tenant of the Orchestrator instance. 34 | 35 | - `orchestrator_user` 36 | Required. The Orchestrator username used for authentication. Must be used together with the password. 37 | 38 | - `orchestrator_pass` 39 | Required. The Orchestrator password used for authentication. Must be used together with the username 40 | 41 | - `UserKey` 42 | Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 43 | 44 | - `account_name` 45 | Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 46 | 47 | - `accountForApp` 48 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 49 | 50 | - `applicationId` 51 | The external application id. Must be used together with account, secret and scope(s) for external application. 52 | 53 | - `applicationSecret` 54 | The external application secret. Must be used together with account, id and scope(s) for external application. 55 | 56 | - `applicationScope` 57 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 58 | 59 | - `folder_organization_unit` 60 | The Orchestrator folder (organization unit). 61 | 62 | - `entryPoints` 63 | 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. 64 | 65 | - `environment_list` 66 | 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 67 | 68 | - `language` 69 | The orchestrator language. 70 | 71 | - `disableTelemetry` 72 | Disable telemetry data. 73 | 74 | - `uipathCliFilePath` 75 | if not provided, the script will auto download the cli from uipath public feed. the script was tested on version 23.10.8753.32995 76 | 77 | - `SpecificCLIVersion` 78 | CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested. -------------------------------------------------------------------------------- /docs/UiPathManageAssets.md: -------------------------------------------------------------------------------- 1 | 2 | # UiPathManageAssets 3 | Manage uipath orchestrator assets. 4 | - Delete assets from an Orchestrator instance (based on asset name). 5 | - Deploy assets to an Orchestrator instance. 6 | ```PowerShell 7 | SYNTAX 8 | . 'C:\scripts\UiPathManageAssets.ps1' [-accountForApp -applicationId -applicationSecret -applicationScope ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-language ] [-uipathCliFilePath ] 9 | 10 | Examples (Deploy Assets): 11 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 12 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization 13 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US 14 | . '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 15 | 16 | Examples (Delete Assets): 17 | . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 18 | . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization 19 | . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US 20 | . '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 21 | 22 | 23 | #Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 24 | ``` 25 | if running on self-hosted agent and UiPath CLI is available on the agent machine, provide `-uipathCliFilePath` 26 | ```PowerShell 27 | Examples: 28 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -uipathCliFilePath "C:\uipathcli\uipcli.exe" 29 | ``` 30 | 31 | More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) 32 | 33 | Script Parameters 34 | - `$operation` 35 | Manage assets operation either 'delete' or 'deploy' 36 | 37 | - `$assets_file` 38 | 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. 39 |
name,type,value,description  
40 |         asset_1_name,text,asset_value # we can have comments,asset_1_description
41 |         asset_2_name,integer,123,asset_2_description
42 |         asset_3_name,boolean,false,asset_3_description
43 |         asset_4_name,credential,"username::password",asset_4_description
44 |         
45 | 46 | - `orchestrator_url` 47 | Required. The URL of the Orchestrator instance. 48 | 49 | - `orchestrator_tenant` 50 | Required. The tenant of the Orchestrator instance. 51 | 52 | - `accountForApp` 53 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 54 | 55 | - `applicationId` 56 | The external application id. Must be used together with account, secret and scope(s) for external application. 57 | 58 | - `applicationSecret` 59 | The external application secret. Must be used together with account, id and scope(s) for external application. 60 | 61 | - `applicationScope` 62 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 63 | 64 | - `orchestrator_user` 65 | Required. The Orchestrator username used for authentication. Must be used together with the password. 66 | 67 | - `orchestrator_pass` 68 | Required. The Orchestrator password used for authentication. Must be used together with the username 69 | 70 | - `UserKey` 71 | Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 72 | 73 | - `account_name` 74 | Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 75 | 76 | - `folder_organization_unit` 77 | The Orchestrator folder (organization unit). 78 | 79 | - `language` 80 | The orchestrator language. 81 | 82 | - `disableTelemetry` 83 | Disable telemetry data. 84 | 85 | - `uipathCliFilePath` 86 | if not provided, the script will auto download the cli from uipath public feed. the script was tested on version 23.10.8753.32995 87 | 88 | - `SpecificCLIVersion` 89 | CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested. -------------------------------------------------------------------------------- /docs/UiPathAnalyzeProject.md: -------------------------------------------------------------------------------- 1 | 2 | # UiPathPack 3 | Check project(s) for workflow analyzer violations 4 | ```PowerShell 5 | SYNTAX 6 | . 'C:\scripts\UiPathAnalyzeProject.ps1' [-analyzerTraceLevel ] [-stopOnRuleViolation ] [-treatWarningsAsErrors ] [-saveOutputToFile] [-ignoredRules ] [-orchestratorUrl -orchestratorTenant ] [-orchestratorUsername -orchestratorPassword ] [-orchestratorAuthToken -orchestratorAccountName ] [-orchestratorFolder ] [-uipathCliFilePath ] 7 | 8 | Examples: 9 | . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" 10 | . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" 11 | . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true 12 | . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true 13 | . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" 14 | . '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" 15 | . '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" 16 | 17 | 18 | #Note: if the script folder location is different, you need to replace "C:" with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 19 | ``` 20 | if running on self-hosted agent and UiPath CLI is available on the agent machine, provide `-uipathCliFilePath` 21 | ```PowerShell 22 | Examples: 23 | . 'C:\scripts\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -uipathCliFilePath "C:\uipathcli\uipcli.exe" 24 | ``` 25 | 26 | More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) 27 | 28 | Script Parameters 29 | - `project_path` 30 | Required. Path to a project.json file or a folder containing project.json files. 31 | 32 | - `analyzerTraceLevel` 33 | Specifies what types of messages to output (Off|Error|Warning|Info|Verbose). 34 | 35 | - `stopOnRuleViolation` 36 | Fail the job when any rule is violated. 37 | 38 | - `treatWarningsAsErrors` 39 | Treat warnings as errors. 40 | 41 | - `resultPath` 42 | The full path to a JSON file where the result json file will be created. Otherwise print it to the standard console. 43 | 44 | - `ignoredRules` 45 | (Default: ) A comma-separated list of rules to be ignored by the analysis procedure. 46 | 47 | - `orchestratorUsername` 48 | (Optional, useful only for additional package feeds) The Orchestrator username used for authentication. Must be used together with the password. 49 | 50 | - `orchestratorPassword` 51 | (Optional, useful only for additional package feeds) The Orchestrator password used for authentication. Must be used together with the username. 52 | 53 | - `orchestratorAuthToken` 54 | (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. 55 | 56 | - `orchestratorAccountName` 57 | (Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 58 | 59 | - `orchestratorAccountForApp` 60 | (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. 61 | 62 | - `orchestratorApplicationId` 63 | (Optional, useful only for additional package feeds) The external application id. Must be used together with account, secret and scope(s) for external application. 64 | 65 | - `orchestratorApplicationSecret` 66 | (Optional, useful only for additional package feeds) The external application secret. Must be used together with account, id and scope(s) for external application. 67 | 68 | - `orchestratorApplicationScope` 69 | (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. 70 | 71 | - `orchestratorFolder` 72 | (Optional, useful only for additional package feeds) The Orchestrator folder (organization unit). 73 | 74 | - `orchestratorUrl` 75 | (Optional, useful only for additional package feeds) The Orchestrator URL. 76 | 77 | - `orchestratorTenant` 78 | (Optional, useful only for additional package feeds) The Orchestrator tenant. 79 | 80 | - `uipathCliFilePath` 81 | if not provided, the script will auto download the cli from uipath public feed. the script was tested on version 23.10.8753.32995 82 | 83 | - `SpecificCLIVersion` 84 | CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Release Notes 3 | ### Released Date 24/04/2024 4 | - testing with the latest [UiPath CLI](https://docs.uipath.com/test-suite/docs/uipath-command-line-interface) as of date ([version 23.10.8753.32995](https://uipath.visualstudio.com/Public.Feeds/_artifacts/feed/UiPath-Official/NuGet/UiPath.CLI.Windows/versions/23.10.8753.32995)) 5 | - user can specify specific CLI version to be auto downloaded from [UiPath CLI](https://uipath.visualstudio.com/Public.Feeds/_artifacts/feed/UiPath-Official/NuGet/UiPath.CLI.Windows/versions) 6 | - add support for new parameters in UiPathRunTest 7 | - bugs fixes 8 | 9 | ### Released Date 13/02/2023 10 | - Upgraded the scripts to use the official [UiPath CLI](https://docs.uipath.com/test-suite/docs/uipath-command-line-interface) 11 | - for self-hosted agents, add paramter to provide path of the UiPath CLI if available on the machine instead of auto downloading the scrip 12 | # UiPath DevOps Scripts 🤖 13 | 14 | Package, deploy, run automations, run tests, manage assets, and analyze automatin projects. 15 | [Youtube Video](https://www.youtube.com/watch?v=asdh8XTUQtQ) The video was created when the library was first released, so it does not include any features added afterward. 16 | [![Youtube Video](https://img.youtube.com/vi/asdh8XTUQtQ/0.jpg)](https://www.youtube.com/watch?v=asdh8XTUQtQ) 17 | 18 | 19 | ## Overview 20 | 21 | More and more customers are requesting integrations of uipath platform to other platforms like GitLab and Circle CI and UiPath is not able to create native plugins for all of them. 22 | 23 | This **unofficial** library of DevOps PowerShell scripts will support customers to facilitate the interaction with the offical UiPath CLI to integrate CI/CD into their workflows and allow them to package, deploy and run automations and tests. 24 | 25 | ## Prerequisite: 26 | 27 | - The provisioned vm or agent should be a window machine 28 | - Add a step in your CI/CD pipepline to download the descired scripts. (Download only the scripts you need, for example if you want to Pack an RPA project then download UiPathPack script) 29 | Use the scripts below as one step in your pipeline and give at any name (e.g. "Preparing Environment") 30 | 31 | It is recommended to download copy of the scripts from the [scripts folder](scripts) into your own repository 32 | ```PowerShell 33 | #Create scripts folder under C drive. (you can change the directory path ) 34 | New-Item -Path "C:\\" -ItemType "directory" -Name "scripts"; 35 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathPack.ps1" -OutFile "C:\\scripts\\UiPathPack.ps1"; 36 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathDeploy.ps1" -OutFile "C:\\scripts\\UiPathDeploy.ps1"; 37 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathJobRun.ps1" -OutFile "C:\\scripts\\UiPathJobRun.ps1"; 38 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathRunTest.ps1" -OutFile "C:\\scripts\\UiPathRunTest.ps1"; 39 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathManageAssets.ps1" -OutFile "C:\\scripts\\UiPathManageAssets.ps1"; 40 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathAnalyzeProject.ps1" -OutFile "C:\\scripts\\UiPathAnalyzeProject.ps1"; 41 | Invoke-WebRequest "https://github.com/UiPath-Services/UiPath-DevOps-Scripts/raw/main/scripts/UiPathCLIGeneric.ps1" -OutFile "C:\\scripts\\UiPathCLIGeneric.ps1"; 42 | ``` 43 | 44 | 45 |
46 | 47 |   You can't create directory outside your CI/CD privisioned machine? 48 | 49 | Some CI/CD tool, like gitlab, may not allow the creation of folder outside the build/working directory . For this you need to place the folder and scripts inside the working directory. In the above script you will need to replace "C:\\" with the the CI/CD tool variable referencing the working directory.
50 | for example,
51 | GitLab $env:CI_PROJECT_DIR
52 | GitHub Actions: ${{github.workspace}}
53 | ..etc
54 | 55 |
56 | 57 | 58 | 59 | ## Powershell Scripts 60 | 61 | Five available scripts can be utilized 62 | 63 | | Script | Description | 64 | | ------------- | ------------- | 65 | | [UiPathPack](docs/UiPathPack.md) | Pack one or more projects into a package. Click on the name for detailed documentation | 66 | | [UiPathDeploy](docs/UiPathDeploy.md) | Deploy packages to an Orchestrator instance, optionally publishing them to a set of environments. Click on the name for detailed documentation | 67 | | [UiPathJobRun](docs/UiPathJobRun.md) | Trigger a job on Orchestrator. Click on the name for detailed documentation | 68 | | [UiPathRunTest](docs/UiPathRunTest.md) | Tests a given package or runs a test set. Click on the name for detailed documentation | 69 | | [UiPathManageAssets](docs/UiPathManageAssets.md) | Manage uipath orchestrator assets. | 70 | | [UiPathAnalyzeProject](docs/UiPathAnalyzeProject.md) | Check project(s) for workflow analyzer violations | 71 | | [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. | 72 | 73 | --- 74 | 75 | 76 | ### PipleLines Samples provided in the video 77 | [CircleCI sample](yaml_samples/circleci_sample.yml) 78 | [GitLab sample](yaml_samples/gitlab_sample.yml) 79 | 80 | ### Logging 81 | 82 | Each script will log all output to its own `*.log` file and sometimes to the console. 83 | 84 | ### Dependency 85 | 86 | `The scripts will automatically download the UiPath.CLI during the runtime.` 87 | - [Official UiPath CLI](https://uipath.visualstudio.com/Public.Feeds/_artifacts/feed/UiPath-Official/NuGet/UiPath.CLI.Windows/overview/23.10.8753.32995) 88 | - UiPath CLI prerequesites: [.NET 6.0.7](https://versionsof.net/core/6.0/6.0.7/), that must include [.NET 6.0.7 Desktop Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0), that come with the 6.0.302 SDK. 89 | 90 | -------------------------------------------------------------------------------- /docs/UiPathJobRun.md: -------------------------------------------------------------------------------- 1 | 2 | # UiPathJobRun 3 | Trigger a job on Orchestrator 4 | ```PowerShell 5 | SYNTAX 6 | . 'C:\scripts\UiPathJobRun.ps1' [-input_path ] [-jobscount ] [-result_path ] [-priority ] [-robots ] 7 | [-fail_when_job_fails ] [-timeout ] [-wait ] [-orchestrator_user -orchestrator_pass ] [-userKey -accountName ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-language ] [-user ] [-machine ] [-job_type ] [-uipathCliFilePath ] 8 | 9 | Example 1: 10 | 11 | . 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 12 | . 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Low 13 | . '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 14 | . '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 15 | . 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -fail_when_job_fails false -timeout 0 16 | . '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 17 | . 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://cloud.uipath.com/" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority Low -robots robotName -result_path C:\Temp 18 | . 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -robots robotName -result_path C:\Temp\status.json 19 | . '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 20 | 21 | 22 | #Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 23 | ``` 24 | if running on self-hosted agent and UiPath CLI is available on the agent machine, provide `-uipathCliFilePath` 25 | ```PowerShell 26 | Examples: 27 | . 'C:\scripts\UiPathJobRun.ps1' "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -uipathCliFilePath "C:\uipathcli\uipcli.exe" 28 | ``` 29 | 30 | More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) 31 | 32 | Script Parameters 33 | - `processName` 34 | orchestrator process name to run. 35 | 36 | - `uriOrch` 37 | The URL of Orchestrator. 38 | 39 | - `tenantlName` 40 | The tenant name 41 | 42 | - `orchestrator_user` 43 | On-premises Orchestrator admin user name who has a Role of Create Package. 44 | 45 | - `orchestrator_pass` 46 | The password of the on-premises Orchestrator admin user. 47 | 48 | - `userKey` 49 | User key for Cloud Platform Orchestrator 50 | 51 | - `accountName` 52 | Account logical name for Cloud Platform Orchestrator 53 | 54 | - `accountForApp` 55 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 56 | 57 | - `applicationId` 58 | The external application id. Must be used together with account, secret and scope(s) for external application. 59 | 60 | - `applicationSecret` 61 | The external application secret. Must be used together with account, id and scope(s) for external application. 62 | 63 | - `applicationScope` 64 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 65 | 66 | - `input_path` 67 | Client ID for Cloud Platform Orchestrator 68 | 69 | - `input_path` 70 | The full path to a JSON input file. Only required if the entry-point workflow has input parameters. 71 | 72 | - `jobscount` 73 | The number of job runs. (default 1) 74 | 75 | - `result_path` 76 | The full path to a JSON file or a folder where the result json file will be created. 77 | 78 | - `priority` 79 | The priority of job runs. One of the following values: Low, Normal, High. (default Normal) 80 | 81 | - `robots` 82 | The comma-separated list of specific robot names. 83 | 84 | - `folder_organization_unit` 85 | The Orchestrator folder (organization unit). 86 | 87 | - `user` 88 | The name of the user. This should be a machine user, not an orchestrator user. For local users, the format should be MachineName\UserName 89 | 90 | - `language` 91 | The orchestrator language. 92 | 93 | - `machine` 94 | The name of the machine. 95 | 96 | - `timeout` 97 | The timeout for job executions in seconds. (default 1800) 98 | 99 | - `fail_when_job_fails` 100 | The command fails when at least one job fails. (default true) 101 | 102 | - `wait` 103 | The command waits for job runs completion. (default true) 104 | 105 | - `job_type` 106 | The type of the job that will run. Values supported for this command: Unattended, NonProduction. For classic folders do not specify this argument 107 | 108 | - `disableTelemetry` 109 | Disable telemetry data. 110 | 111 | - `uipathCliFilePath` 112 | if not provided, the script will auto download the cli from uipath public feed. the script was tested on version 23.10.8753.32995 113 | 114 | - `SpecificCLIVersion` 115 | CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested. -------------------------------------------------------------------------------- /docs/UiPathRunTest.md: -------------------------------------------------------------------------------- 1 | 2 | # UiPathRunTest 3 | Tests a given package or runs a test set. 4 | ```PowerShell 5 | SYNTAX 6 | . '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 ] [-uipathCliFilePath ] 7 | 8 | Examples: 9 | . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -testset "MyRobotTests" 10 | . '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 11 | . '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 12 | . '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 13 | . '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" 14 | . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -testset "MyRobotTests" 15 | . '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 16 | . '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 17 | . '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 18 | . '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 -attachRobotLogs "true" 19 | 20 | #Note: if script folder location is different you need to replace C: with directory folder (e.g. '[FOLDER_VARIABLE]\scripts\UiPathPack.ps1') 21 | ``` 22 | if running on self-hosted agent and UiPath CLI is available on the agent machine, provide `-uipathCliFilePath` 23 | ```PowerShell 24 | Examples: 25 | . 'C:\scripts\UiPathRunTest.ps1' -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -testset "MyRobotTests" -uipathCliFilePath "C:\uipathcli\uipcli.exe" 26 | ``` 27 | More on different authentication options here [UiPathAuthenticationsOptions](UiPathAuthenticationsOptions.md) 28 | 29 | Script Parameters 30 | - `project_path` 31 | The path to a test package file. 32 | 33 | - `testset` 34 | 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 35 | 36 | - `orchestrator_url` 37 | Required. The URL of the Orchestrator instance. 38 | 39 | - `orchestrator_tenant` 40 | Required. The tenant of the Orchestrator instance. 41 | 42 | - `result_path` 43 | Results file path 44 | 45 | - `accountForApp` 46 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 47 | 48 | - `applicationId` 49 | The external application id. Must be used together with account, secret and scope(s) for external application. 50 | 51 | - `applicationSecret` 52 | The external application secret. Must be used together with account, id and scope(s) for external application. 53 | 54 | - `applicationScope` 55 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 56 | 57 | - `orchestrator_user` 58 | Required. The Orchestrator username used for authentication. Must be used together with the password. 59 | 60 | - `orchestrator_pass` 61 | Required. The Orchestrator password used for authentication. Must be used together with the username 62 | 63 | - `UserKey` 64 | Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 65 | 66 | - `account_name` 67 | Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 68 | 69 | - `folder_organization_unit` 70 | The Orchestrator folder (organization unit). 71 | 72 | - `environment` 73 | The environment to deploy the package to. Must be used together with the project path. Required when not using a modern folder. 74 | 75 | - `timeout` 76 | The time in seconds for waiting to finish test set executions. (default 7200) 77 | 78 | - `out` 79 | Type of result file 80 | 81 | - `language` 82 | The orchestrator language. 83 | 84 | - `disableTelemetry` 85 | Disable telemetry data. 86 | 87 | - `uipathCliFilePath` 88 | if not provided, the script will auto download the cli from uipath public feed. the script was tested on version 23.10.8753.32995 89 | 90 | - `SpecificCLIVersion` 91 | CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested. 92 | 93 | - `attachRobotLogs` 94 | Attaches Robot Logs for each testcases along with Junit Test Report. 95 | 96 | - `repositoryUrl` 97 | Repository url where project is versioned. 98 | 99 | - `repositoryCommit` 100 | Repository commit where the project was built from. 101 | 102 | - `repositoryBranch` 103 | Repository branch where the project was built from. 104 | 105 | - `repositoryType` 106 | VCS system repository type. 107 | 108 | - `projectUrl` 109 | Automation Hub idea URL. 110 | 111 | - `identityUrl` 112 | Url of your identity server. This is only required for PaaS deployments. -------------------------------------------------------------------------------- /scripts/UiPathDeploy.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Deploy NuGet package files to orchestrator 4 | 5 | .DESCRIPTION 6 | This script is to deploy NuGet package files (*.nupkg) to Cloud or On-Prem orchestrator. 7 | 8 | .PARAMETER packages_path 9 | Required. The path to a folder containing packages, or to a package file. 10 | 11 | .PARAMETER orchestrator_url 12 | Required. The URL of the Orchestrator instance. 13 | 14 | .PARAMETER orchestrator_tenant 15 | Required. The tenant of the Orchestrator instance. 16 | 17 | .PARAMETER accountForApp 18 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 19 | 20 | .PARAMETER applicationId 21 | The external application id. Must be used together with account, secret and scope(s) for external application. 22 | 23 | .PARAMETER applicationSecret 24 | The external application secret. Must be used together with account, id and scope(s) for external application. 25 | 26 | .PARAMETER applicationScope 27 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 28 | 29 | .PARAMETER orchestrator_user 30 | Required. The Orchestrator username used for authentication. Must be used together with the password. 31 | 32 | .PARAMETER orchestrator_pass 33 | Required. The Orchestrator password used for authentication. Must be used together with the username 34 | 35 | .PARAMETER UserKey 36 | Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 37 | 38 | .PARAMETER account_name 39 | Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 40 | 41 | .PARAMETER folder_organization_unit 42 | The Orchestrator folder (organization unit). 43 | 44 | .PARAMETER environment_list 45 | 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 46 | 47 | .PARAMETER entryPoints 48 | 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. 49 | 50 | .PARAMETER language 51 | The orchestrator language. 52 | 53 | .PARAMETER disableTelemetry 54 | Disable telemetry data. 55 | 56 | .PARAMETER uipathCliFilePath 57 | if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 22.10.8432.18709. if provided, it is recommended to have cli version 22.10.8432.18709 58 | 59 | .EXAMPLE 60 | SYNTAX 61 | . '\UiPathDeploy.ps1' [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-environment_list ] [-language ] 62 | 63 | Examples: 64 | . '\UiPathDeploy.ps1' "C:\UiPath\Project 1" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 65 | . '\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 66 | . '\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 67 | . '\UiPathDeploy.ps1' "C:\UiPath\Project\Package.1.0.6820.22047.nupkg" "https://uipath-orchestrator.myorg.com" default -UserKey a7da29a2c93a717110a82 -account_name myAccount 68 | . '\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" 69 | . '\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 70 | #> 71 | Param ( 72 | 73 | #Required 74 | [Parameter(Mandatory=$true, Position = 0)] 75 | [string] $packages_path = "", # Required. The path to a folder containing packages, or to a package file. 76 | [Parameter(Mandatory=$true, Position = 1)] 77 | [string] $orchestrator_url = "", #Required. The URL of the Orchestrator instance. 78 | [Parameter(Mandatory=$true, Position = 2)] 79 | [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. 80 | 81 | 82 | #External Apps (Option 1) 83 | [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 84 | [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. 85 | [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. 86 | [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. 87 | 88 | #API Access - (Option 2) 89 | [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 90 | [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 91 | 92 | #On prem - (Option 3) 93 | [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. 94 | [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username 95 | 96 | [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). 97 | [string] $language = "", #The orchestrator language. 98 | [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 99 | [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. 100 | [string] $disableTelemetry = "", #Disable telemetry data. 101 | [string] $uipathCliFilePath = "" , #if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 23.10.8753.32995. 102 | [string] $SpecificCLIVersion = "", #CLI version to auto download if uipathCliFilePath not provided 103 | [Parameter(ValueFromRemainingArguments = $true)] 104 | $remainingArgs 105 | 106 | 107 | 108 | 109 | ) 110 | #Log function 111 | function WriteLog 112 | { 113 | Param ($message, [switch] $err) 114 | 115 | $now = Get-Date -Format "G" 116 | $line = "$now`t$message" 117 | $line | Add-Content $debugLog -Encoding UTF8 118 | if ($err) 119 | { 120 | Write-Host $line -ForegroundColor red 121 | } else { 122 | Write-Host $line 123 | } 124 | } 125 | #Running Path 126 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 127 | #log file 128 | $debugLog = "$scriptPath\orchestrator-package-deploy.log" 129 | 130 | #Validate provided cli folder (if any) 131 | if($uipathCliFilePath -ne ""){ 132 | $uipathCLI = "$uipathCliFilePath" 133 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 134 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 135 | exit 1 136 | } 137 | }else{ 138 | #Verifying UiPath CLI installation 139 | if($SpecificCLIVersion -ne ""){ 140 | $cliVersion = $SpecificCLIVersion; 141 | } 142 | else{ 143 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 144 | } 145 | 146 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 147 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 148 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 149 | try { 150 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 151 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 152 | } 153 | #Download UiPath CLI 154 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 155 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 156 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 157 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 158 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 159 | WriteLog "Unable to locate uipath cli after it is downloaded." 160 | exit 1 161 | } 162 | } 163 | catch { 164 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 165 | exit 1 166 | } 167 | 168 | } 169 | } 170 | WriteLog "-----------------------------------------------------------------------------" 171 | WriteLog "uipcli location : $uipathCLI" 172 | #END Verifying UiPath CLI installation 173 | 174 | 175 | $ParamList = New-Object 'Collections.Generic.List[string]' 176 | 177 | #region Verifying required paramteters 178 | if($packages_path -eq "" -or $orchestrator_url -eq "" -or $orchestrator_tenant -eq "") 179 | { 180 | WriteLog "Fill the required paramters (packages_path, orchestrator_url, orchestrator_tenant)" 181 | exit 1 182 | } 183 | 184 | if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") 185 | { 186 | if($account_name -eq "" -or $UserKey -eq "") 187 | { 188 | if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") 189 | { 190 | WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" 191 | exit 1 192 | } 193 | } 194 | } 195 | #endregion Verifying required paramteters 196 | 197 | #Building uipath cli paramters 198 | $ParamList.Add("package") 199 | $ParamList.Add("deploy") 200 | $ParamList.Add("`"$packages_path`"") 201 | $ParamList.Add($orchestrator_url) 202 | $ParamList.Add($orchestrator_tenant) 203 | 204 | if($accountForApp -ne ""){ 205 | $ParamList.Add("--accountForApp") 206 | $ParamList.Add($accountForApp) 207 | } 208 | if($applicationId -ne ""){ 209 | $ParamList.Add("--applicationId") 210 | $ParamList.Add($applicationId) 211 | } 212 | if($applicationSecret -ne ""){ 213 | $ParamList.Add("--applicationSecret") 214 | $ParamList.Add($applicationSecret) 215 | } 216 | if($applicationScope -ne ""){ 217 | $ParamList.Add("--applicationScope") 218 | $ParamList.Add("`"$applicationScope`"") 219 | } 220 | if($account_name -ne ""){ 221 | $ParamList.Add("--accountName") 222 | $ParamList.Add($account_name) 223 | } 224 | if($UserKey -ne ""){ 225 | $ParamList.Add("--token") 226 | $ParamList.Add($UserKey) 227 | } 228 | if($orchestrator_user -ne ""){ 229 | $ParamList.Add("--username") 230 | $ParamList.Add($orchestrator_user) 231 | } 232 | if($orchestrator_pass -ne ""){ 233 | $ParamList.Add("--password") 234 | $ParamList.Add($orchestrator_pass) 235 | } 236 | if($folder_organization_unit -ne ""){ 237 | $ParamList.Add("--organizationUnit") 238 | $ParamList.Add("`"$folder_organization_unit`"") 239 | } 240 | if($environment_list -ne ""){ 241 | $ParamList.Add("--environments") 242 | $ParamList.Add("`"$environment_list`"") 243 | } 244 | 245 | if($language -ne ""){ 246 | $ParamList.Add("--language") 247 | $ParamList.Add($language) 248 | } 249 | 250 | if($disableTelemetry -ne ""){ 251 | $ParamList.Add("--disableTelemetry") 252 | $ParamList.Add($disableTelemetry) 253 | } 254 | if($entryPoints -ne ""){ 255 | $ParamList.Add("--entryPointsPath") 256 | $ParamList.Add("`"$entryPoints`"") 257 | } 258 | 259 | #mask sensitive info before logging 260 | $ParamMask = New-Object 'Collections.Generic.List[string]' 261 | $ParamMask.AddRange($ParamList) 262 | $secretIndex = $ParamMask.IndexOf("--password"); 263 | if($secretIndex -ge 0){ 264 | $ParamMask[$secretIndex + 1] = ("*" * 15) 265 | } 266 | $secretIndex = $ParamMask.IndexOf("--token"); 267 | if($secretIndex -ge 0){ 268 | $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) 269 | } 270 | $secretIndex = $ParamMask.IndexOf("--applicationId"); 271 | if($secretIndex -ge 0){ 272 | $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) 273 | } 274 | $secretIndex = $ParamMask.IndexOf("--applicationSecret"); 275 | if($secretIndex -ge 0){ 276 | $ParamMask[$secretIndex + 1] = ("*" * 15) 277 | } 278 | 279 | #log cli call with parameters 280 | WriteLog "Executing $uipathCLI $ParamMask" 281 | WriteLog "-----------------------------------------------------------------------------" 282 | 283 | #call uipath cli 284 | & "$uipathCLI" $ParamList.ToArray() 285 | 286 | if($LASTEXITCODE -eq 0) 287 | { 288 | WriteLog "Done!" 289 | Exit 0 290 | }else { 291 | WriteLog "Unable to deploy project. Exit code $LASTEXITCODE" 292 | Exit 1 293 | } 294 | -------------------------------------------------------------------------------- /scripts/UiPathPack.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Pack project into a NuGet package 4 | 5 | .DESCRIPTION 6 | This script is to pack a project into a NuGet package files (*.nupkg). 7 | 8 | .PARAMETER project_path 9 | Required. Path to a project.json file or a folder containing project.json files. 10 | 11 | .PARAMETER destination_folder 12 | Required. Destination folder. 13 | 14 | .PARAMETER libraryOrchestratorUrl 15 | (Optional, useful only for libraries) The Orchestrator URL. 16 | 17 | .PARAMETER libraryOrchestratorTenant 18 | (Optional, useful only for libraries) The Orchestrator tenant. 19 | 20 | .PARAMETER libraryOrchestratorAccountForApp 21 | (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 22 | 23 | .PARAMETER libraryOrchestratorApplicationId 24 | (Optional, useful only for libraries) The external application id. Must be used together with account, secret and scope(s) for external application. 25 | 26 | .PARAMETER libraryOrchestratorApplicationSecret 27 | (Optional, useful only for libraries) The external application secret. Must be used together with account, id and scope(s) for external application. 28 | 29 | .PARAMETER libraryOrchestratorApplicationScope 30 | (Optional, useful only for libraries) The space-separated list of application scopes. Must be used together with account, id and secret for external application. 31 | 32 | .PARAMETER libraryOrchestratorUsername 33 | (Optional, useful only for libraries) The Orchestrator password used for authentication. Must be used together with the username. 34 | 35 | .PARAMETER libraryOrchestratorPassword 36 | (Optional, useful only for libraries) The Orchestrator username used for authentication. Must be used together with the password. 37 | 38 | .PARAMETER libraryOrchestratorUserKey 39 | (Optional, useful only for libraries) The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 40 | 41 | .PARAMETER libraryOrchestratorAccountName 42 | (Optional, useful only for libraries) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 43 | 44 | .PARAMETER libraryOrchestratorFolder 45 | (Optional, useful only for libraries) The Orchestrator folder (organization unit). 46 | 47 | .PARAMETER version 48 | Package version. 49 | 50 | .PARAMETER autoVersion 51 | Auto-generate package version. 52 | 53 | .PARAMETER outputType 54 | Force the output to a specific type. 55 | 56 | .PARAMETER language 57 | The orchestrator language. 58 | 59 | .PARAMETER disableTelemetry 60 | Disable telemetry data. 61 | 62 | .PARAMETER uipathCliFilePath 63 | if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 22.10.8432.18709. if provided, it is recommended to have cli version 22.10.8432.18709 64 | 65 | .EXAMPLE 66 | SYNTAX: 67 | .\UiPathPack.ps1 -destination_folder [-version ] [-autoVersion] [--outputType ] [--libraryOrchestratorUrl --libraryOrchestratorTenant ] [--libraryOrchestratorUsername --libraryOrchestratorPassword ] [--libraryOrchestratorUserKey --libraryOrchestratorAccountName ] [--libraryOrchestratorFolder ] [-language ] 68 | 69 | Examples: 70 | package pack "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" 71 | package pack "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -version 1.0.6820.22047 72 | package pack "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -autoVersion 73 | package pack "C:\UiPath\Project" -destination_folder "C:\UiPath\Package" 74 | package pack "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" --outputType Tests -language en-US 75 | 76 | .\UiPathPack.ps1 -o [-version ] [-autoVersion] [-outputType ] [-libraryOrchestratorUrl -libraryOrchestratorTenant ] [-libraryOrchestratorUsername -libraryOrchestratorPassword ] [-libraryOrchestratorUserKey -libraryOrchestratorAccountName ] [-libraryOrchestratorAccountForApp -libraryOrchestratorApplicationId -libraryOrchestratorApplicationSecret -libraryOrchestratorApplicationScope ] 77 | [-libraryOrchestratorFolder ] [-language ] 78 | 79 | Examples: 80 | .\UiPathPack.ps1 "C:\UiPath\Project\project.json" --destination_folder "C:\UiPath\Package" 81 | .\UiPathPack.ps1 "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -version 1.0.6820.22047 82 | .\UiPathPack.ps1 "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -autoVersion 83 | .\UiPathPack.ps1 "C:\UiPath\Project" -destination_folder "C:\UiPath\Package" 84 | .\UiPathPack.ps1 "C:\UiPath\Project\project.json" -destination_folder "C:\UiPath\Package" -outputType Tests -language en-US 85 | #> 86 | Param ( 87 | 88 | #Required 89 | [Parameter(Mandatory=$true, Position = 0)] 90 | [string] $project_path = "", # Required. Path to a project.json file or a folder containing project.json files. 91 | [string] $destination_folder = "", #Required. Destination folder. 92 | [string] $libraryOrchestratorUrl = "", #Required. The URL of the Orchestrator instance. 93 | [string] $libraryOrchestratorTenant = "", #(Optional, useful only for libraries) The Orchestrator tenant. 94 | 95 | #Extranal Apps (OAuth) (Cloud/OnPrem) 96 | [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. 97 | [string] $libraryOrchestratorApplicationId = "", #(Optional, useful only for libraries) The external application id. Must be used together with account, secret and scope(s) for external application. 98 | [string] $libraryOrchestratorApplicationSecret = "", #(Optional, useful only for libraries) The external application secret. Must be used together with account, id and scope(s) for external application. 99 | [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. 100 | 101 | #cloud API Access - Required 102 | [string] $libraryOrchestratorAccountName = "", #(Optional, useful only for libraries) The Orchestrator URL. 103 | [string] $libraryOrchestratorUserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 104 | 105 | #On prem - Required 106 | [string] $libraryOrchestratorUsername = "", #Required. The Orchestrator username used for authentication. Must be used together with the libraryOrchestratorPassword. 107 | [string] $libraryOrchestratorPassword = "", #Required. The Orchestrator password used for authentication. Must be used together with the libraryOrchestratorUsername. 108 | 109 | [string] $libraryOrchestratorFolder = "", #Optional, useful only for libraries) The Orchestrator folder (organization unit). 110 | [string] $language = "", #The orchestrator language. 111 | [string] $version = "", #Package version. 112 | [switch] $autoVersion, #Auto-generate package version. 113 | [string] $outputType = "", #Force the output to a specific type. 114 | [string] $disableTelemetry = "", #Disable telemetry data. 115 | [string] $uipathCliFilePath = "", #if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 23.10.8753.32995. 116 | [string] $SpecificCLIVersion = "", #CLI version to auto download if uipathCliFilePath not provided 117 | [Parameter(ValueFromRemainingArguments = $true)] 118 | $remainingArgs 119 | 120 | 121 | 122 | ) 123 | #Log function 124 | function WriteLog 125 | { 126 | Param ($message, [switch] $err) 127 | 128 | $now = Get-Date -Format "G" 129 | $line = "$now`t$message" 130 | $line | Add-Content $debugLog -Encoding UTF8 131 | if ($err) 132 | { 133 | Write-Host $line -ForegroundColor red 134 | } else { 135 | Write-Host $line 136 | } 137 | } 138 | 139 | #Running Path 140 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 141 | #log file 142 | $debugLog = "$scriptPath\orchestrator-package-pack.log" 143 | 144 | #Validate provided cli folder (if any) 145 | if($uipathCliFilePath -ne ""){ 146 | $uipathCLI = "$uipathCliFilePath" 147 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 148 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 149 | exit 1 150 | } 151 | }else{ 152 | 153 | if($SpecificCLIVersion -ne ""){ 154 | $cliVersion = $SpecificCLIVersion; 155 | } 156 | else{ 157 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 158 | } 159 | #Verifying UiPath CLI installation 160 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 161 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 162 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 163 | try { 164 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 165 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 166 | } 167 | #Download UiPath CLI 168 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 169 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 170 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 171 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 172 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 173 | WriteLog "Unable to locate uipath cli after it is downloaded." 174 | exit 1 175 | } 176 | } 177 | catch { 178 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 179 | exit 1 180 | } 181 | 182 | } 183 | } 184 | WriteLog "-----------------------------------------------------------------------------" 185 | WriteLog "uipcli location : $uipathCLI" 186 | #END Verifying UiPath CLI installation 187 | 188 | 189 | #Building uipath cli paramters 190 | $ParamList = New-Object 'Collections.Generic.List[string]' 191 | 192 | if($project_path -eq "" -or $destination_folder -eq "") 193 | { 194 | WriteLog "Fill the required paramters (project_path, destination_folder)" 195 | exit 1 196 | } 197 | $ParamList.Add("package") 198 | $ParamList.Add("pack") 199 | $ParamList.Add("`"$project_path`"") 200 | $ParamList.Add("--output") 201 | $ParamList.Add("`"$destination_folder`"") 202 | 203 | if($libraryOrchestratorUrl -ne ""){ 204 | $ParamList.Add("--libraryOrchestratorUrl") 205 | $ParamList.Add($libraryOrchestratorUrl) 206 | } 207 | if($libraryOrchestratorTenant -ne ""){ 208 | $ParamList.Add("--libraryOrchestratorTenant") 209 | $ParamList.Add($libraryOrchestratorTenant) 210 | } 211 | if($libraryOrchestratorAccountName -ne ""){ 212 | $ParamList.Add("--libraryOrchestratorAccountName") 213 | $ParamList.Add($libraryOrchestratorAccountName) 214 | } 215 | if($libraryOrchestratorUserKey -ne ""){ 216 | $ParamList.Add("--libraryOrchestratorAuthToken") 217 | $ParamList.Add($libraryOrchestratorUserKey) 218 | } 219 | if($libraryOrchestratorUsername -ne ""){ 220 | $ParamList.Add("--libraryOrchestratorUsername") 221 | $ParamList.Add($libraryOrchestratorUsername) 222 | } 223 | if($libraryOrchestratorPassword -ne ""){ 224 | $ParamList.Add("--libraryOrchestratorPassword") 225 | $ParamList.Add($libraryOrchestratorPassword) 226 | } 227 | if($libraryOrchestratorAccountForApp -ne ""){ 228 | $ParamList.Add("--libraryOrchestratorAccountForApp") 229 | $ParamList.Add($libraryOrchestratorAccountForApp) 230 | } 231 | if($libraryOrchestratorApplicationId -ne ""){ 232 | $ParamList.Add("--libraryOrchestratorApplicationId") 233 | $ParamList.Add($libraryOrchestratorApplicationId) 234 | } 235 | if($libraryOrchestratorApplicationSecret -ne ""){ 236 | $ParamList.Add("--libraryOrchestratorApplicationSecret") 237 | $ParamList.Add($libraryOrchestratorApplicationSecret) 238 | } 239 | if($libraryOrchestratorApplicationScope -ne ""){ 240 | $ParamList.Add("--libraryOrchestratorApplicationScope") 241 | $ParamList.Add("`"$libraryOrchestratorApplicationScope`"") 242 | } 243 | if($libraryOrchestratorFolder -ne ""){ 244 | $ParamList.Add("--libraryOrchestratorFolder") 245 | $ParamList.Add("`"$libraryOrchestratorFolder`"") 246 | } 247 | if($language -ne ""){ 248 | $ParamList.Add("--language") 249 | $ParamList.Add($language) 250 | } 251 | if($version -ne ""){ 252 | $ParamList.Add("--version") 253 | $ParamList.Add($version) 254 | } 255 | if($PSBoundParameters.ContainsKey('autoVersion')) { 256 | $ParamList.Add("--autoVersion") 257 | } 258 | if($outputType -ne ""){ 259 | $ParamList.Add("--outputType") 260 | $ParamList.Add($outputType) 261 | } 262 | 263 | if($disableTelemetry -ne ""){ 264 | $ParamList.Add("--disableTelemetry") 265 | $ParamList.Add($disableTelemetry) 266 | } 267 | 268 | 269 | #region Mask sensitive info before logging 270 | $ParamMask = New-Object 'Collections.Generic.List[string]' 271 | $ParamMask.AddRange($ParamList) 272 | $secretIndex = $ParamMask.IndexOf("--libraryOrchestratorPassword"); 273 | if($secretIndex -ge 0){ 274 | $ParamMask[$secretIndex + 1] = ("*" * 15) 275 | } 276 | $secretIndex = $ParamMask.IndexOf("--libraryOrchestratorAuthToken"); 277 | if($secretIndex -ge 0){ 278 | $ParamMask[$secretIndex + 1] = $libraryOrchestratorUserKey.Substring(0, [Math]::Min(4, $libraryOrchestratorUserKey.Length)) + ("*" * 15) 279 | } 280 | $secretIndex = $ParamMask.IndexOf("--libraryOrchestratorApplicationId"); 281 | if($secretIndex -ge 0){ 282 | $ParamMask[$secretIndex + 1] = $libraryOrchestratorApplicationId.Substring(0, [Math]::Min($libraryOrchestratorApplicationId.Length, 4)) + ("*" * 15) 283 | } 284 | $secretIndex = $ParamMask.IndexOf("--libraryOrchestratorApplicationSecret"); 285 | if($secretIndex -ge 0){ 286 | $ParamMask[$secretIndex + 1] = ("*" * 15) 287 | } 288 | #endregion Mask sensitive info before logging 289 | 290 | #log cli call with parameters 291 | WriteLog "Executing $uipathCLI $ParamMask" 292 | WriteLog "-----------------------------------------------------------------------------" 293 | #call uipath cli 294 | & "$uipathCLI" $ParamList.ToArray() 295 | 296 | if($LASTEXITCODE -eq 0) 297 | { 298 | WriteLog "Done! Package(s) destination folder is : $destination_folder" 299 | Exit 0 300 | }else { 301 | WriteLog "Unable to Pack project. Exit code $LASTEXITCODE" 302 | Exit 1 303 | } 304 | -------------------------------------------------------------------------------- /scripts/UiPathManageAssets.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Manage uipath orchestrator assets 4 | 5 | .DESCRIPTION 6 | Delete assets from an Orchestrator instance (based on asset name). 7 | Deploy assets to an Orchestrator instance. 8 | 9 | .PARAMETER $operation 10 | Manage assets operation (delete | deploy) 11 | 12 | .PARAMETER $assets_file 13 | 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. 14 | asset_1_name,text,asset_value # we can have comments,asset_1_description 15 | asset_2_name,integer,123,asset_2_description 16 | asset_3_name,boolean,false,asset_3_description 17 | asset_4_name,credential,"username::password",asset_4_description 18 | 19 | .PARAMETER orchestrator_url 20 | Required. The URL of the Orchestrator instance. 21 | 22 | .PARAMETER orchestrator_tenant 23 | Required. The tenant of the Orchestrator instance. 24 | 25 | .PARAMETER accountForApp 26 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 27 | 28 | .PARAMETER applicationId 29 | The external application id. Must be used together with account, secret and scope(s) for external application. 30 | 31 | .PARAMETER applicationSecret 32 | The external application secret. Must be used together with account, id and scope(s) for external application. 33 | 34 | .PARAMETER applicationScope 35 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 36 | 37 | .PARAMETER orchestrator_user 38 | Required. The Orchestrator username used for authentication. Must be used together with the password. 39 | 40 | .PARAMETER orchestrator_pass 41 | Required. The Orchestrator password used for authentication. Must be used together with the username 42 | 43 | .PARAMETER UserKey 44 | Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 45 | 46 | .PARAMETER account_name 47 | Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 48 | 49 | .PARAMETER folder_organization_unit 50 | The Orchestrator folder (organization unit). 51 | 52 | 53 | .PARAMETER language 54 | The orchestrator language. 55 | 56 | .PARAMETER disableTelemetry 57 | Disable telemetry data. 58 | 59 | .PARAMETER uipathCliFilePath 60 | if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 22.10.8432.18709. if provided, it is recommended to have cli version 22.10.8432.18709 61 | 62 | .EXAMPLE 63 | SYNTAX 64 | . 'C:\scripts\UiPathManageAssets.ps1' [-accountForApp -applicationId -applicationSecret -applicationScope ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-folder_organization_unit ] [-language ] 65 | 66 | Examples (Deploy Assets): 67 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 68 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization 69 | . 'C:\scripts\UiPathManageAssets.ps1' deploy assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US 70 | . '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 71 | 72 | Examples (Delete Assets): 73 | . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 74 | . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://uipath-orchestrator.myorg.com" defaultTenant -orchestrator_user admin -orchestrator_pass 123456 -folder_organization_unit OurOrganization 75 | . 'C:\scripts\UiPathManageAssets.ps1' delete assets_file.csv "https://cloud.uipath.com" defaultTenant -UserKey a7da29a2c93a717110a82 -account_name myAccount -language en-US 76 | . '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 77 | 78 | #> 79 | Param ( 80 | 81 | #Required 82 | [Parameter(Mandatory=$true, Position = 0)] 83 | [string] $operation = "", #Manage assets operation (delete | deploy) 84 | [Parameter(Mandatory=$true, Position = 1)] 85 | [string] $assets_file = "", #Assets file 86 | [Parameter(Mandatory=$true, Position = 2)] 87 | [string] $orchestrator_url = "", #Required. The URL of the Orchestrator instance. 88 | [Parameter(Mandatory=$true, Position = 3)] 89 | [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. 90 | 91 | #External Apps (Option 1) 92 | [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 93 | [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. 94 | [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. 95 | [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. 96 | 97 | #API Access - (Option 2) 98 | [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 99 | [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 100 | 101 | #On prem - (Option 3) 102 | [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. 103 | [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username 104 | 105 | [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). 106 | [string] $language = "", #-l, --language The orchestrator language. 107 | [string] $disableTelemetry = "", #-y, --disableTelemetry Disable telemetry data. 108 | [string] $timeout = "", # The time in seconds for waiting to finish test set executions. (default 7200) 109 | [string] $uipathCliFilePath = "" , #if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 23.10.8753.32995. 110 | [string] $SpecificCLIVersion = "", #CLI version to auto download if uipathCliFilePath not provided 111 | [Parameter(ValueFromRemainingArguments = $true)] 112 | $remainingArgs 113 | 114 | ) 115 | 116 | function WriteLog 117 | { 118 | Param ($message, [switch] $err) 119 | 120 | $now = Get-Date -Format "G" 121 | $line = "$now`t$message" 122 | $line | Add-Content $debugLog -Encoding UTF8 123 | if ($err) 124 | { 125 | Write-Host $line -ForegroundColor red 126 | } else { 127 | Write-Host $line 128 | } 129 | } 130 | #Running Path 131 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 132 | #log file 133 | $debugLog = "$scriptPath\orchestrator-test-run.log" 134 | 135 | #Validate provided cli folder (if any) 136 | if($uipathCliFilePath -ne ""){ 137 | $uipathCLI = "$uipathCliFilePath" 138 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 139 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 140 | exit 1 141 | } 142 | }else{ 143 | #Verifying UiPath CLI installation 144 | if($SpecificCLIVersion -ne ""){ 145 | $cliVersion = $SpecificCLIVersion; 146 | } 147 | else{ 148 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 149 | } 150 | 151 | 152 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 153 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 154 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 155 | try { 156 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 157 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 158 | } 159 | #Download UiPath CLI 160 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 161 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 162 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 163 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 164 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 165 | WriteLog "Unable to locate uipath cli after it is downloaded." 166 | exit 1 167 | } 168 | } 169 | catch { 170 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 171 | exit 1 172 | } 173 | 174 | } 175 | } 176 | WriteLog "-----------------------------------------------------------------------------" 177 | WriteLog "uipcli location : $uipathCLI" 178 | #endregion Verifying UiPath CLI installation 179 | 180 | $ParamList = New-Object 'Collections.Generic.List[string]' 181 | 182 | #region validate input paramters 183 | if($operation -ne "delete" -and $operation -ne "deploy"){ 184 | WriteLog "invalid operation. operation must either be 'delete' or 'deploy'. You typed '$operation'" 185 | exit 1 186 | } 187 | 188 | #full path of asset file 189 | if(-not($assets_file.Contains("\"))) 190 | { 191 | $assets_file = "$scriptPath\$assets_file" 192 | } 193 | if (-not(Test-Path -Path $assets_file -PathType Leaf)) { 194 | WriteLog "assets file does not exist in ($assets_file)" 195 | exit 1 196 | } 197 | if($orchestrator_url -eq "" -or $orchestrator_tenant -eq "") 198 | { 199 | WriteLog "Fill the required paramters (orchestrator_url, orchestrator_tenant)" 200 | exit 1 201 | } 202 | 203 | #required parameters (Cloud accountName and userkey) or (on-prem username and password) 204 | if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") 205 | { 206 | if($account_name -eq "" -or $UserKey -eq "") 207 | { 208 | if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") 209 | { 210 | WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" 211 | exit 1 212 | } 213 | } 214 | } 215 | #endregion validate input paramters 216 | 217 | 218 | #region Building uipath cli paramters 219 | $ParamList.Add("asset") 220 | $ParamList.Add("$operation") 221 | $ParamList.Add("`"$assets_file`"") 222 | $ParamList.Add($orchestrator_url) 223 | $ParamList.Add($orchestrator_tenant) 224 | 225 | if($accountForApp -ne ""){ 226 | $ParamList.Add("--accountForApp") 227 | $ParamList.Add($accountForApp) 228 | } 229 | if($applicationId -ne ""){ 230 | $ParamList.Add("--applicationId") 231 | $ParamList.Add($applicationId) 232 | } 233 | if($applicationSecret -ne ""){ 234 | $ParamList.Add("--applicationSecret") 235 | $ParamList.Add($applicationSecret) 236 | } 237 | if($applicationScope -ne ""){ 238 | $ParamList.Add("--applicationScope") 239 | $ParamList.Add("`"$applicationScope`"") 240 | } 241 | if($account_name -ne ""){ 242 | $ParamList.Add("--accountName") 243 | $ParamList.Add($account_name) 244 | } 245 | if($UserKey -ne ""){ 246 | $ParamList.Add("--token") 247 | $ParamList.Add($UserKey) 248 | } 249 | if($orchestrator_user -ne ""){ 250 | $ParamList.Add("--username") 251 | $ParamList.Add($orchestrator_user) 252 | } 253 | if($orchestrator_pass -ne ""){ 254 | $ParamList.Add("--password") 255 | $ParamList.Add($orchestrator_pass) 256 | } 257 | if($folder_organization_unit -ne ""){ 258 | $ParamList.Add("--organizationUnit") 259 | $ParamList.Add("`"$folder_organization_unit`"") 260 | } 261 | if($language -ne ""){ 262 | $ParamList.Add("--language") 263 | $ParamList.Add($language) 264 | } 265 | 266 | if($disableTelemetry -ne ""){ 267 | $ParamList.Add("--disableTelemetry") 268 | $ParamList.Add($disableTelemetry) 269 | } 270 | #endregion Building uipath cli paramters 271 | 272 | #Mask sensitive infos before loging 273 | $ParamMask = New-Object 'Collections.Generic.List[string]' 274 | $ParamMask.AddRange($ParamList) 275 | $secretIndex = $ParamMask.IndexOf("--password"); 276 | if($secretIndex -ge 0){ 277 | $ParamMask[$secretIndex + 1] = ("*" * 15) 278 | } 279 | $secretIndex = $ParamMask.IndexOf("--token"); 280 | if($secretIndex -ge 0){ 281 | $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) 282 | } 283 | $secretIndex = $ParamMask.IndexOf("--applicationId"); 284 | if($secretIndex -ge 0){ 285 | $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) 286 | } 287 | $secretIndex = $ParamMask.IndexOf("--applicationSecret"); 288 | if($secretIndex -ge 0){ 289 | $ParamMask[$secretIndex + 1] = ("*" * 15) 290 | } 291 | #log cli call with parameters 292 | WriteLog "Executing $uipathCLI $ParamMask" 293 | 294 | #call uipath cli 295 | & "$uipathCLI" $ParamList.ToArray() 296 | 297 | if($LASTEXITCODE -eq 0) 298 | { 299 | WriteLog "Done!" 300 | Exit 0 301 | }else { 302 | WriteLog "Unable to execute command. Exit code $LASTEXITCODE" 303 | Exit 1 304 | } 305 | -------------------------------------------------------------------------------- /scripts/UiPathAnalyzeProject.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Check project(s) for workflow analyzer violations 4 | 5 | .DESCRIPTION 6 | This script is used to analyze UiPath Studio Project for Warrning & Errors. 7 | 8 | .PARAMETER ProjectPath 9 | Required. Path to a project.json file or a folder containing project.json files. 10 | 11 | .PARAMETER analyzerTraceLevel 12 | Specifies what types of messages to output (Off|Error|Warning|Info|Verbose). 13 | 14 | .PARAMETER stopOnRuleViolation 15 | Fail the job when any rule is violated. 16 | 17 | .PARAMETER treatWarningsAsErrors 18 | Treat warnings as errors. 19 | 20 | .PARAMETER resultPath 21 | The full path to a JSON file where the result json file will be created. Otherwise print it to the standard console. 22 | 23 | .PARAMETER ignoredRules 24 | (Default: ) A comma-separated list of rules to be ignored by the analysis procedure. 25 | 26 | .PARAMETER orchestratorUsername 27 | (Optional, useful only for additional package feeds) The Orchestrator username used for authentication. Must be used together with the password. 28 | 29 | .PARAMETER orchestratorPassword 30 | (Optional, useful only for additional package feeds) The Orchestrator password used for authentication. Must be used together with the username. 31 | 32 | .PARAMETER orchestratorAuthToken 33 | (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. 34 | 35 | .PARAMETER orchestratorAccountName 36 | (Optional, useful only for additional package feeds) The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 37 | 38 | .PARAMETER orchestratorAccountForApp 39 | (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. 40 | 41 | .PARAMETER orchestratorApplicationId 42 | (Optional, useful only for additional package feeds) The external application id. Must be used together with account, secret and scope(s) for external application. 43 | 44 | .PARAMETER orchestratorApplicationSecret 45 | (Optional, useful only for additional package feeds) The external application secret. Must be used together with account, id and scope(s) for external application. 46 | 47 | .PARAMETER orchestratorApplicationScope 48 | (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. 49 | 50 | .PARAMETER orchestratorFolder 51 | (Optional, useful only for additional package feeds) The Orchestrator folder (organization unit). 52 | 53 | .PARAMETER orchestratorUrl 54 | (Optional, useful only for additional package feeds) The Orchestrator URL. 55 | 56 | .PARAMETER orchestratorTenant 57 | (Optional, useful only for additional package feeds) The Orchestrator tenant. 58 | 59 | .PARAMETER uipathCliFilePath 60 | if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 23.10.8753.32995 61 | 62 | .EXAMPLE 63 | SYNTAX 64 | . '\UiPathAnalyzeProject.ps1' [-analyzerTraceLevel ] [-stopOnRuleViolation ] [-treatWarningsAsErrors ] [-saveOutputToFile] [-ignoredRules ] [-orchestratorUrl -orchestratorTenant ] [-orchestratorUsername -orchestratorPassword ] [-orchestratorAuthToken -orchestratorAccountName ] [-orchestratorFolder ] 65 | Examples: 66 | . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" 67 | . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" 68 | . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true 69 | . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true 70 | . '\UiPathAnalyzeProject.ps1' "C:\UiPath\Project\project.json" -analyzerTraceLevel "Error" -stopOnRuleViolation true -treatWarningsAsErrors true -resultPath "C:\UiPath\Project\output.json" 71 | . '\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" 72 | . '\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" 73 | . '\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" -orchestratorFolder "OrchestratorFolder" -orchestratorAccountForApp AccountName -orchestratorApplicationId e5b7*************** -orchestratorApplicationSecret *************** -orchestratorApplicationScope "OR.Analytics OR.Assets OR.Audit OR.BackgroundTasks OR.Execution OR.Folders OR.Jobs OR.Machines OR.Monitoring OR.Queues OR.Robots.Read OR.Settings OR.Tasks OR.TestSetExecutions OR.Users.Read" 74 | #> 75 | Param ( 76 | 77 | #Required 78 | 79 | [Parameter(Mandatory=$true, Position = 0)] 80 | [string] $ProjectPath = "", # Required. Path to a project.json file or a folder containing project.json files. 81 | [string] $analyzerTraceLevel = "", #Specifies what types of messages to output (Off|Error|Warning|Info|Verbose). 82 | [string] $stopOnRuleViolation = "", #Fail the job when any rule is violated. 83 | [string] $treatWarningsAsErrors = "", #Treat warnings as errors. 84 | [string] $resultPath = "", #The full path to a JSON file where the result json file will be created. Otherwise print it to the standard console. 85 | [string] $ignoredRules = "", #(Default: ) A comma-separated list of rules to be ignored by the analysis procedure. 86 | [string] $orchestratorUsername = "", #(Optional, useful only for additional package feeds) The Orchestrator username used for authentication. Must be used together with the password. 87 | [string] $orchestratorPassword = "", #(Optional, useful only for additional package feeds) The Orchestrator password used for authentication. Must be used together with the username. 88 | [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. 89 | [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. 90 | [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. 91 | [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. 92 | [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. 93 | [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. 94 | [string] $orchestratorFolder = "", #(Optional, useful only for additional package feeds) The Orchestrator folder (organization unit). 95 | [string] $orchestratorUrl = "", #(Optional, useful only for additional package feeds) The Orchestrator URL. 96 | [string] $orchestratorTenant = "", #(Optional, useful only for additional package feeds) The Orchestrator tenant. 97 | [string] $uipathCliFilePath = "", #if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 22.10.8432.18709. if provided, it is recommended to have cli version 22.10.8432.18709 98 | [Parameter(ValueFromRemainingArguments = $true)] 99 | $remainingArgs 100 | 101 | ) 102 | #Log function 103 | function WriteLog 104 | { 105 | Param ($message, [switch] $err) 106 | 107 | $now = Get-Date -Format "G" 108 | $line = "$now`t$message" 109 | $line | Add-Content $debugLog -Encoding UTF8 110 | if ($err) 111 | { 112 | Write-Host $line -ForegroundColor red 113 | } else { 114 | Write-Host $line 115 | } 116 | } 117 | #Running Path 118 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 119 | #log file 120 | $debugLog = "$scriptPath\orchestrator-package-analyze.log" 121 | 122 | #Validate provided cli folder (if any) 123 | if($uipathCliFilePath -ne ""){ 124 | $uipathCLI = "$uipathCliFilePath" 125 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 126 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 127 | exit 1 128 | } 129 | }else{ 130 | #Verifying UiPath CLI installation 131 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 132 | 133 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 134 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 135 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 136 | try { 137 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 138 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 139 | } 140 | #Download UiPath CLI 141 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 142 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 143 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 144 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 145 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 146 | WriteLog "Unable to locate uipath cli after it is downloaded." 147 | exit 1 148 | } 149 | } 150 | catch { 151 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 152 | exit 1 153 | } 154 | 155 | } 156 | } 157 | WriteLog "-----------------------------------------------------------------------------" 158 | WriteLog "uipcli location : $uipathCLI" 159 | #END Verifying UiPath CLI installation 160 | 161 | 162 | $ParamList = New-Object 'Collections.Generic.List[string]' 163 | 164 | #region Verifying required paramteters 165 | if($ProjectPath -eq "") 166 | { 167 | WriteLog "Fill the required paramters (packagesPath)" 168 | exit 1 169 | } 170 | 171 | #endregion Verifying required paramteters 172 | 173 | #Building uipath cli paramters 174 | $ParamList.Add("package") 175 | $ParamList.Add("analyze") 176 | $ParamList.Add("`"$ProjectPath`"") 177 | 178 | 179 | if($analyzerTraceLevel -ne ""){ 180 | $ParamList.Add("--analyzerTraceLevel") 181 | $ParamList.Add($analyzerTraceLevel) 182 | } 183 | if($stopOnRuleViolation -ne ""){ 184 | if($stopOnRuleViolation.Trim().ToLower() -eq "true"){ 185 | $ParamList.Add("--stopOnRuleViolation") 186 | } 187 | } 188 | if($treatWarningsAsErrors -ne ""){ 189 | if($treatWarningsAsErrors.Trim().ToLower() -eq "true"){ 190 | $ParamList.Add("--treatWarningsAsErrors") 191 | } 192 | } 193 | if($resultPath -ne ""){ 194 | $ParamList.Add("--resultPath") 195 | $ParamList.Add($resultPath) 196 | } 197 | if($ignoredRules -ne ""){ 198 | $ParamList.Add("--ignoredRules") 199 | $ParamList.Add("`"$ignoredRules`"") 200 | } 201 | if($orchestratorUsername -ne ""){ 202 | $ParamList.Add("--orchestratorUsername") 203 | $ParamList.Add($orchestratorUsername) 204 | } 205 | if($orchestratorPassword -ne ""){ 206 | $ParamList.Add("--orchestratorPassword") 207 | $ParamList.Add($orchestratorPassword) 208 | } 209 | if($orchestratorAuthToken -ne ""){ 210 | $ParamList.Add("--orchestratorAuthToken") 211 | $ParamList.Add($orchestratorAuthToken) 212 | } 213 | if($orchestratorAccountName -ne ""){ 214 | $ParamList.Add("--orchestratorAccountName") 215 | $ParamList.Add($orchestratorAccountName) 216 | } 217 | if($orchestratorAccountForApp -ne ""){ 218 | $ParamList.Add("--orchestratorAccountForApp") 219 | $ParamList.Add($orchestratorAccountForApp) 220 | } 221 | if($orchestratorApplicationId -ne ""){ 222 | $ParamList.Add("--orchestratorApplicationId") 223 | $ParamList.Add($orchestratorApplicationId) 224 | } 225 | if($orchestratorApplicationSecret -ne ""){ 226 | $ParamList.Add("--orchestratorApplicationSecret") 227 | $ParamList.Add($orchestratorApplicationSecret) 228 | } 229 | if($orchestratorApplicationScope -ne ""){ 230 | $ParamList.Add("--orchestratorApplicationScope") 231 | $ParamList.Add("`"$orchestratorApplicationScope`"") 232 | } 233 | if($orchestratorFolder -ne ""){ 234 | $ParamList.Add("--orchestratorFolder") 235 | $ParamList.Add($orchestratorFolder) 236 | } 237 | if($orchestratorUrl -ne ""){ 238 | $ParamList.Add("--orchestratorUrl") 239 | $ParamList.Add($orchestratorUrl) 240 | } 241 | if($orchestratorTenant -ne ""){ 242 | $ParamList.Add("--orchestratorTenant") 243 | $ParamList.Add($orchestratorTenant) 244 | } 245 | 246 | 247 | 248 | 249 | #mask sensitive info before logging 250 | $ParamMask = New-Object 'Collections.Generic.List[string]' 251 | $ParamMask.AddRange($ParamList) 252 | $secretIndex = $ParamMask.IndexOf("--orchestratorPassword"); 253 | if($secretIndex -ge 0){ 254 | $ParamMask[$secretIndex + 1] = ("*" * 15) 255 | } 256 | $secretIndex = $ParamMask.IndexOf("--orchestratorAuthToken"); 257 | if($secretIndex -ge 0){ 258 | $ParamMask[$secretIndex + 1] = $orchestratorAuthToken.Substring(0, [Math]::Min($orchestratorAuthToken.Length, 4)) + ("*" * 15) 259 | } 260 | $secretIndex = $ParamMask.IndexOf("--orchestratorApplicationId"); 261 | if($secretIndex -ge 0){ 262 | $ParamMask[$secretIndex + 1] = $orchestratorApplicationId.Substring(0, [Math]::Min($orchestratorApplicationId.Length, 4)) + ("*" * 15) 263 | } 264 | $secretIndex = $ParamMask.IndexOf("--orchestratorApplicationSecret"); 265 | if($secretIndex -ge 0){ 266 | $ParamMask[$secretIndex + 1] = ("*" * 15) 267 | } 268 | 269 | #log cli call with parameters 270 | WriteLog "Executing $uipathCLI $ParamMask" 271 | WriteLog "-----------------------------------------------------------------------------" 272 | 273 | #call uipath cli 274 | & "$uipathCLI" $ParamList.ToArray() 275 | 276 | if($LASTEXITCODE -eq 0) 277 | { 278 | WriteLog "Done!" 279 | Exit 0 280 | }else { 281 | WriteLog "Analyzer returned errors or unable to analyze the project. Exit code $LASTEXITCODE" 282 | Exit 1 283 | } 284 | -------------------------------------------------------------------------------- /scripts/UiPathJobRun.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Run UiPath Orchestrator Job. 4 | 5 | .DESCRIPTION 6 | This script is to run orchestrator job. 7 | 8 | .PARAMETER processName 9 | orchestrator process name to run. 10 | 11 | .PARAMETER uriOrch 12 | The URL of Orchestrator. 13 | 14 | .PARAMETER tenantlName 15 | The tenant name 16 | 17 | .PARAMETER accountForApp 18 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 19 | 20 | .PARAMETER applicationId 21 | The external application id. Must be used together with account, secret and scope(s) for external application. 22 | 23 | .PARAMETER applicationSecret 24 | The external application secret. Must be used together with account, id and scope(s) for external application. 25 | 26 | .PARAMETER applicationScope 27 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 28 | 29 | .PARAMETER orchestrator_user 30 | On-premises Orchestrator admin user name who has a Role of Create Package. 31 | 32 | .PARAMETER orchestrator_pass 33 | The password of the on-premises Orchestrator admin user. 34 | 35 | .PARAMETER userKey 36 | User key for Cloud Platform Orchestrator 37 | 38 | .PARAMETER accountName 39 | Account logical name for Cloud Platform Orchestrator 40 | 41 | .PARAMETER input_path 42 | The full path to a JSON input file. Only required if the entry-point workflow has input parameters. 43 | 44 | .PARAMETER jobscount 45 | The number of job runs. (default 1) 46 | 47 | .PARAMETER result_path 48 | The full path to a JSON file or a folder where the result json file will be created. 49 | 50 | .PARAMETER priority 51 | The priority of job runs. One of the following values: Low, Normal, High. (default Normal) 52 | 53 | .PARAMETER robots 54 | The comma-separated list of specific robot names. 55 | 56 | .PARAMETER folder_organization_unit 57 | The Orchestrator folder (organization unit). 58 | 59 | .PARAMETER user 60 | The name of the user. This should be a machine user, not an orchestrator user. For local users, the format should be MachineName\UserName 61 | 62 | .PARAMETER language 63 | The orchestrator language. 64 | 65 | .PARAMETER machine 66 | The name of the machine. 67 | 68 | .PARAMETER timeout 69 | The timeout for job executions in seconds. (default 1800) 70 | 71 | .PARAMETER fail_when_job_fails 72 | The command fails when at least one job fails. (default true) 73 | 74 | .PARAMETER wait 75 | The command waits for job runs completion. (default true) 76 | 77 | .PARAMETER job_type 78 | The type of the job that will run. Values supported for this command: Unattended, NonProduction. For classic folders do not specify this argument 79 | 80 | .PARAMETER disableTelemetry 81 | Disable telemetry data. 82 | 83 | .PARAMETER uipathCliFilePath 84 | if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 22.10.8432.18709. if provided, it is recommended to have cli version 22.10.8432.18709 85 | 86 | .EXAMPLE 87 | SYNTAX: 88 | .\UiPathJobRun.ps1 [-input_path ] [-jobscount ] [-result_path ] [-priority ] [-robots ] 89 | [-fail_when_job_fails ] [-timeout ] [-wait ] [-orchestrator_user -orchestrator_pass ] [-userKey -accountName ] 90 | [-accountForApp -applicationId -applicationSecret -applicationScope ] [-folder_organization_unit ] [-language ] [-user ] 91 | [-machine ] [-job_type ] 92 | 93 | Examples: 94 | 95 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 96 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Low 97 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority Normal -folder_organization_unit MyFolder 98 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -orchestrator_user admin -orchestrator_pass 123456 -orchestrator_pass -priority High -folder_organization_unit MyFolder 99 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -fail_when_job_fails false -timeout 0 100 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority High -jobscount 3 -wait false -machine ROBOTMACHINE 101 | .\UiPathJobRun.ps1 "ProcessName" "https://cloud.uipath.com/" default -userKey a7da29a2c93a717110a82 -accountName myAccount -orchestrator_pass -priority Low -robots robotName -result_path C:\Temp 102 | .\UiPathJobRun.ps1 "ProcessName" "https://uipath-orchestrator.myorg.com" default -userKey a7da29a2c93a717110a82 -accountName myAccount -robots robotName -result_path C:\Temp\status.json 103 | .\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 104 | 105 | #> 106 | Param ( 107 | 108 | #Required 109 | [Parameter(Mandatory=$true, Position = 0)] 110 | [string] $processName = "", #Process Name (pos. 0) Required. 111 | [Parameter(Mandatory=$true, Position = 1)] 112 | [string] $uriOrch = "", #Orchestrator URL (pos. 1) Required. The URL of the Orchestrator instance. 113 | [Parameter(Mandatory=$true, Position = 2)] 114 | [string] $tenantlName = "", #Orchestrator Tenant (pos. 2) Required. The tenant of the Orchestrator instance. 115 | 116 | #External Apps (Option 1) 117 | [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 118 | [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. 119 | [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. 120 | [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. 121 | 122 | #API Access - (Option 2) 123 | [string] $accountName = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 124 | [string] $userKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 125 | 126 | #On prem UserName & Password - (Option 3) 127 | [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. 128 | [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username. 129 | 130 | [string] $input_path = "", #The full path to a JSON input file. Only required if the entry-point workflow has input parameters. 131 | [string] $jobscount = "", #The number of job runs. (default 1) 132 | [string] $result_path = "", #The full path to a JSON file or a folder where the result json file will be created. 133 | [string] $priority = "", #The priority of job runs. One of the following values: Low, Normal, High. (default Normal) 134 | [string] $robots = "", #The comma-separated list of specific robot names. 135 | [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). 136 | [string] $language = "", #The orchestrator language. 137 | [string] $user = "", #The name of the user. This should be a machine user, not an orchestrator user. For local users, the format should be MachineName\UserName 138 | [string] $machine = "", #The name of the machine. 139 | [string] $timeout = "", #The timeout for job executions in seconds. (default 1800) 140 | [string] $fail_when_job_fails = "", #The command fails when at least one job fails. (default true) 141 | [string] $wait = "", #The command waits for job runs completion. (default true) 142 | [string] $job_type = "", #The type of the job that will run. Values supported for this command: Unattended, NonProduction. For classic folders do not specify this argument 143 | [string] $disableTelemetry = "", #Disable telemetry data. 144 | [string] $uipathCliFilePath = "" , #if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 23.10.8753.32995. 145 | [string] $SpecificCLIVersion = "", #CLI version to auto download if uipathCliFilePath not provided 146 | [Parameter(ValueFromRemainingArguments = $true)] 147 | $remainingArgs 148 | 149 | ) 150 | function WriteLog 151 | { 152 | Param ($message, [switch] $err) 153 | 154 | $now = Get-Date -Format "G" 155 | $line = "$now`t$message" 156 | $line | Add-Content $debugLog -Encoding UTF8 157 | if ($err) 158 | { 159 | Write-Host $line -ForegroundColor red 160 | } else { 161 | Write-Host $line 162 | } 163 | } 164 | #Running Path 165 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 166 | #log file 167 | $debugLog = "$scriptPath\orchestrator-job-run.log" 168 | 169 | #Validate provided cli folder (if any) 170 | if($uipathCliFilePath -ne ""){ 171 | $uipathCLI = "$uipathCliFilePath" 172 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 173 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 174 | exit 1 175 | } 176 | }else{ 177 | #Verifying UiPath CLI installation 178 | 179 | if($SpecificCLIVersion -ne ""){ 180 | $cliVersion = $SpecificCLIVersion; 181 | } 182 | else{ 183 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 184 | } 185 | 186 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 187 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 188 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 189 | try { 190 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 191 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 192 | } 193 | #Download UiPath CLI 194 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 195 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 196 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 197 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 198 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 199 | WriteLog "Unable to locate uipath cli after it is downloaded." 200 | exit 1 201 | } 202 | } 203 | catch { 204 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 205 | exit 1 206 | } 207 | 208 | } 209 | } 210 | WriteLog "-----------------------------------------------------------------------------" 211 | WriteLog "uipcli location : $uipathCLI" 212 | #END Verifying UiPath CLI installation 213 | 214 | $ParamList = New-Object 'Collections.Generic.List[string]' 215 | 216 | if($processName -eq "" -or $uriOrch -eq "" -or $tenantlName -eq "") 217 | { 218 | WriteLog "Fill the required paramters (processName, uriOrch, tenantlName)" 219 | exit 1 220 | } 221 | 222 | if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") 223 | { 224 | if($accountName -eq "" -or $userKey -eq "") 225 | { 226 | if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") 227 | { 228 | WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" 229 | exit 1 230 | } 231 | } 232 | } 233 | 234 | #Building uipath cli paramters 235 | $ParamList.Add("job") 236 | $ParamList.Add("run") 237 | $ParamList.Add($processName) 238 | $ParamList.Add($uriOrch) 239 | $ParamList.Add($tenantlName) 240 | 241 | if($accountForApp -ne ""){ 242 | $ParamList.Add("--accountForApp") 243 | $ParamList.Add($accountForApp) 244 | } 245 | if($applicationId -ne ""){ 246 | $ParamList.Add("--applicationId") 247 | $ParamList.Add($applicationId) 248 | } 249 | if($applicationSecret -ne ""){ 250 | $ParamList.Add("--applicationSecret") 251 | $ParamList.Add($applicationSecret) 252 | } 253 | if($applicationScope -ne ""){ 254 | $ParamList.Add("--applicationScope") 255 | $ParamList.Add("`"$applicationScope`"") 256 | } 257 | if($accountName -ne ""){ 258 | $ParamList.Add("--accountName") 259 | $ParamList.Add($accountName) 260 | } 261 | if($userKey -ne ""){ 262 | $ParamList.Add("--token") 263 | $ParamList.Add($userKey) 264 | 265 | } 266 | if($orchestrator_user -ne ""){ 267 | $ParamList.Add("--username") 268 | $ParamList.Add($orchestrator_user) 269 | } 270 | if($orchestrator_pass -ne ""){ 271 | $ParamList.Add("--password") 272 | $ParamList.Add($orchestrator_pass) 273 | } 274 | if($input_path -ne ""){ 275 | $ParamList.Add("--input_path") 276 | $ParamList.Add("`"$input_path`"") 277 | } 278 | if($jobscount -ne ""){ 279 | $ParamList.Add("--jobscount") 280 | $ParamList.Add($jobscount) 281 | } 282 | if($result_path -ne ""){ 283 | $ParamList.Add("--result_path") 284 | $ParamList.Add("`"$result_path`"") 285 | } 286 | if($priority -ne ""){ 287 | $ParamList.Add("--priority") 288 | $ParamList.Add($priority) 289 | } 290 | if($robots -ne ""){ 291 | $ParamList.Add("--robots") 292 | $ParamList.Add("`"$robots`"") 293 | } 294 | if($folder_organization_unit -ne ""){ 295 | $ParamList.Add("--organizationUnit") 296 | $ParamList.Add("`"$folder_organization_unit`"") 297 | } 298 | if($language -ne ""){ 299 | $ParamList.Add("--language") 300 | $ParamList.Add($language) 301 | } 302 | if($user -ne ""){ 303 | $ParamList.Add("--user") 304 | $ParamList.Add($user) 305 | } 306 | if($machine -ne ""){ 307 | $ParamList.Add("--machine") 308 | $ParamList.Add($machine) 309 | } 310 | if($timeout -ne ""){ 311 | $ParamList.Add("--timeout") 312 | $ParamList.Add($timeout) 313 | } 314 | if($fail_when_job_fails -ne ""){ 315 | $ParamList.Add("--fail_when_job_fails") 316 | $ParamList.Add($fail_when_job_fails) 317 | } 318 | if($wait -ne ""){ 319 | $ParamList.Add("--wait") 320 | $ParamList.Add($wait) 321 | } 322 | if($job_type -ne ""){ 323 | $ParamList.Add("--job_type") 324 | $ParamList.Add($job_type) 325 | } 326 | if($disableTelemetry -ne ""){ 327 | $ParamList.Add("--disableTelemetry") 328 | $ParamList.Add($disableTelemetry) 329 | } 330 | 331 | #mask sensitive info before logging 332 | $ParamMask = New-Object 'Collections.Generic.List[string]' 333 | $ParamMask.AddRange($ParamList) 334 | $secretIndex = $ParamMask.IndexOf("--password"); 335 | if($secretIndex -ge 0){ 336 | $ParamMask[$secretIndex + 1] = ("*" * 15) 337 | } 338 | $secretIndex = $ParamMask.IndexOf("--token"); 339 | if($secretIndex -ge 0){ 340 | $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) 341 | } 342 | $secretIndex = $ParamMask.IndexOf("--applicationId"); 343 | if($secretIndex -ge 0){ 344 | $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) 345 | } 346 | $secretIndex = $ParamMask.IndexOf("--applicationSecret"); 347 | if($secretIndex -ge 0){ 348 | $ParamMask[$secretIndex + 1] = ("*" * 15) 349 | } 350 | 351 | #log cli call with parameters 352 | WriteLog "Executing $uipathCLI $ParamMask" 353 | WriteLog "-----------------------------------------------------------------------------" 354 | 355 | #call uipath cli 356 | & "$uipathCLI" $ParamList.ToArray() 357 | 358 | if($LASTEXITCODE -eq 0) 359 | { 360 | WriteLog "Done!" 361 | Exit 0 362 | }else { 363 | WriteLog "Unable to run process. Exit code $LASTEXITCODE" 364 | Exit 1 365 | } -------------------------------------------------------------------------------- /scripts/UiPathRunTest.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Test a given package or run a test set 4 | 5 | .DESCRIPTION 6 | Test a given package or run a test set in orchestrator 7 | 8 | .PARAMETER project_path 9 | The path to a test package file. 10 | 11 | .PARAMETER input_path 12 | 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. 13 | 14 | .PARAMETER testset 15 | 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 16 | 17 | .PARAMETER orchestrator_url 18 | Required. The URL of the Orchestrator instance. 19 | 20 | .PARAMETER orchestrator_tenant 21 | Required. The tenant of the Orchestrator instance. 22 | 23 | .PARAMETER result_path 24 | Results file path 25 | 26 | .PARAMETER accountForApp 27 | The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 28 | 29 | .PARAMETER applicationId 30 | The external application id. Must be used together with account, secret and scope(s) for external application. 31 | 32 | .PARAMETER applicationSecret 33 | The external application secret. Must be used together with account, id and scope(s) for external application. 34 | 35 | .PARAMETER applicationScope 36 | The space-separated list of application scopes. Must be used together with account, id and secret for external application. 37 | 38 | .PARAMETER orchestrator_user 39 | Required. The Orchestrator username used for authentication. Must be used together with the password. 40 | 41 | .PARAMETER orchestrator_pass 42 | Required. The Orchestrator password used for authentication. Must be used together with the username 43 | 44 | .PARAMETER UserKey 45 | Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 46 | 47 | .PARAMETER account_name 48 | Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 49 | 50 | .PARAMETER folder_organization_unit 51 | The Orchestrator folder (organization unit). 52 | 53 | .PARAMETER environment 54 | The environment to deploy the package to. Must be used together with the project path. Required when not using a modern folder. 55 | 56 | .PARAMETER timeout 57 | The time in seconds for waiting to finish test set executions. (default 7200) 58 | 59 | .PARAMETER out 60 | Type of result file 61 | 62 | .PARAMETER language 63 | The orchestrator language. 64 | 65 | .PARAMETER disableTelemetry 66 | Disable telemetry data. 67 | 68 | .PARAMETER uipathCliFilePath 69 | if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 22.10.8432.18709. if provided, it is recommended to have cli version 22.10.8432.18709 70 | 71 | .PARAMETER attachRobotLogs 72 | Attaches Robot Logs for each testcases along with Junit Test Report. 73 | 74 | .PARAMETER repositoryUrl 75 | Repository url where project is versioned. 76 | 77 | .PARAMETER repositoryCommit 78 | Repository commit where the project was built from. 79 | 80 | .PARAMETER repositoryBranch 81 | Repository branch where the project was built from. 82 | 83 | .PARAMETER repositoryType 84 | VCS system repository type. 85 | 86 | .PARAMETER projectUrl 87 | Automation Hub idea URL. 88 | 89 | .PARAMETER identityUrl 90 | Url of your identity server. This is only required for PaaS deployments. 91 | 92 | 93 | .EXAMPLE 94 | SYNTAX 95 | .\UiPathRunTest.ps1 [-input_path ] [-project_path ] [-testset ] [-orchestrator_user -orchestrator_pass ] [-UserKey -account_name ] [-accountForApp -applicationId -applicationSecret -applicationScope ] [-environment ] [-folder_organization_unit ] [-language ] 96 | 97 | Examples: 98 | .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -orchestrator_user admin -orchestrator_pass 123456 -testset "MyRobotTests" 99 | .\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 100 | .\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 101 | .\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 102 | .\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" 103 | .\UiPathRunTest.ps1 -orchestrator_url "https://uipath-orchestrator.myorg.com" -orchestrator_tenant default -UserKey a7da29a2c93a717110a82 -account_name myAccount -testset "MyRobotTests" 104 | .\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 105 | .\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 106 | .\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 107 | #> 108 | Param ( 109 | 110 | #Required 111 | [string] $orchestrator_url = "", #Required. The URL of the Orchestrator instance. 112 | [string] $orchestrator_tenant = "", #Required. The tenant of the Orchestrator instance. 113 | 114 | [string] $project_path = "", #The path to a test package file. 115 | [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. 116 | [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 117 | 118 | [string] $result_path = "", #Results file path 119 | 120 | #External Apps (Option 1) 121 | [string] $accountForApp = "", #The Orchestrator CloudRPA account name. Must be used together with id, secret and scope(s) for external application. 122 | [string] $applicationId = "", #Required. The external application id. Must be used together with account, secret and scope(s) for external application. 123 | [string] $applicationSecret = "", #Required. The external application secret. Must be used together with account, id and scope(s) for external application. 124 | [string] $applicationScope = "", #Required. The space-separated list of application scopes. Must be used together with account, id and secret for external application. 125 | 126 | #API Access - (Option 2) 127 | [string] $account_name = "", #Required. The Orchestrator CloudRPA account name. Must be used together with the refresh token and client id. 128 | [string] $UserKey = "", #Required. The Orchestrator OAuth2 refresh token used for authentication. Must be used together with the account name and client id. 129 | 130 | #On prem - Required 131 | [string] $orchestrator_user = "", #Required. The Orchestrator username used for authentication. Must be used together with the password. 132 | [string] $orchestrator_pass = "", #Required. The Orchestrator password used for authentication. Must be used together with the username 133 | 134 | [string] $folder_organization_unit = "", #The Orchestrator folder (organization unit). 135 | [string] $language = "", #-l, --language The orchestrator language. 136 | [string] $environment = "", #The environment to deploy the package to. Must be used together with the project path. Required when not using a modern folder. 137 | [string] $disableTelemetry = "", #-y, --disableTelemetry Disable telemetry data. 138 | [string] $timeout = "", # The time in seconds for waiting to finish test set executions. (default 7200) 139 | [string] $out = "", #Type of result file 140 | [string] $traceLevel = "", 141 | [string] $uipathCliFilePath = "", #if not provided, the script will auto download the cli from uipath public feed. the script was testing on version 23.10.8753.32995. 142 | [string] $SpecificCLIVersion = "", #CLI version to auto download if uipathCliFilePath not provided. Default is "23.10.8753.32995" where the script was last tested, 143 | 144 | [string] $attachRobotLogs = "", #Attaches Robot Logs for each testcases along with Junit Test Report. 145 | [string] $repositoryUrl = "", #Repository url where project is versioned. 146 | [string] $repositoryCommit = "", # Repository commit where the project was built from. 147 | [string] $repositoryBranch = "", # Repository branch where the project was built from. 148 | [string] $repositoryType = "", # VCS system repository type. 149 | [string] $projectUrl = "", # Automation Hub idea URL. 150 | [string] $identityUrl = "", #Url of your identity server. This is only required for PaaS deployments. 151 | 152 | [Parameter(ValueFromRemainingArguments = $true)] 153 | $remainingArgs 154 | 155 | ) 156 | function WriteLog 157 | { 158 | Param ($message, [switch] $err) 159 | 160 | $now = Get-Date -Format "G" 161 | $line = "$now`t$message" 162 | $line | Add-Content $debugLog -Encoding UTF8 163 | if ($err) 164 | { 165 | Write-Host $line -ForegroundColor red 166 | } else { 167 | Write-Host $line 168 | } 169 | } 170 | #Running Path 171 | $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path 172 | #log file 173 | $debugLog = "$scriptPath\orchestrator-test-run.log" 174 | 175 | #Validate provided cli folder (if any) 176 | if($uipathCliFilePath -ne ""){ 177 | $uipathCLI = "$uipathCliFilePath" 178 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 179 | WriteLog "UiPath cli file path provided does not exist in the provided path $uipathCliFilePath.`r`nDo not provide uipathCliFilePath paramter if you want the script to auto download the cli from UiPath Public feed" 180 | exit 1 181 | } 182 | }else{ 183 | #Verifying UiPath CLI installation 184 | if($SpecificCLIVersion -ne ""){ 185 | $cliVersion = $SpecificCLIVersion; 186 | } 187 | else{ 188 | $cliVersion = "23.10.8753.32995"; #CLI Version (Script was tested on this latest version at the time) 189 | } 190 | 191 | $uipathCLI = "$scriptPath\uipathcli\$cliVersion\tools\uipcli.exe" 192 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 193 | WriteLog "UiPath CLI does not exist in this folder. Attempting to download it..." 194 | try { 195 | if (-not(Test-Path -Path "$scriptPath\uipathcli\$cliVersion" -PathType Leaf)){ 196 | New-Item -Path "$scriptPath\uipathcli\$cliVersion" -ItemType "directory" -Force | Out-Null 197 | } 198 | #Download UiPath CLI 199 | #Invoke-WebRequest "https://www.myget.org/F/uipath-dev/api/v2/package/UiPath.CLI/$cliVersion" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 200 | Invoke-WebRequest "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/$cliVersion/content" -OutFile "$scriptPath\\uipathcli\\$cliVersion\\cli.zip"; 201 | Expand-Archive -LiteralPath "$scriptPath\\uipathcli\\$cliVersion\\cli.zip" -DestinationPath "$scriptPath\\uipathcli\\$cliVersion"; 202 | WriteLog "UiPath CLI is downloaded and extracted in folder $scriptPath\uipathcli\\$cliVersion" 203 | if (-not(Test-Path -Path $uipathCLI -PathType Leaf)) { 204 | WriteLog "Unable to locate uipath cli after it is downloaded." 205 | exit 1 206 | } 207 | } 208 | catch { 209 | WriteLog ("Error Occured : " + $_.Exception.Message) -err $_.Exception 210 | exit 1 211 | } 212 | 213 | } 214 | } 215 | WriteLog "-----------------------------------------------------------------------------" 216 | WriteLog "uipcli location : $uipathCLI" 217 | #END Verifying UiPath CLI installation 218 | 219 | 220 | $ParamList = New-Object 'Collections.Generic.List[string]' 221 | 222 | if($orchestrator_url -eq "" -or $orchestrator_tenant -eq "") 223 | { 224 | WriteLog "Fill the required paramters (orchestrator_url, orchestrator_tenant)" 225 | exit 1 226 | } 227 | 228 | #required parameters (Authintication) 229 | if($accountForApp -eq "" -or $applicationId -eq "" -or $applicationSecret -eq "" -or $applicationScope -eq "") 230 | { 231 | if($account_name -eq "" -or $userKey -eq "") 232 | { 233 | if($orchestrator_user -eq "" -or $orchestrator_pass -eq "") 234 | { 235 | WriteLog "Fill the required paramters (External App OAuth, API Access, or Username & Password)" 236 | exit 1 237 | } 238 | } 239 | } 240 | if($project_path -eq "" -and $testset -eq "") 241 | { 242 | WriteLog "Either TestSet or Project path is required to fill" 243 | exit 1 244 | } 245 | #Building uipath cli paramters 246 | $ParamList.Add("test") 247 | $ParamList.Add("run") 248 | $ParamList.Add($orchestrator_url) 249 | $ParamList.Add($orchestrator_tenant) 250 | 251 | if($project_path -ne ""){ 252 | $ParamList.Add("--project-path") 253 | $ParamList.Add("`"$project_path`"") 254 | } 255 | if($input_path -ne ""){ 256 | $ParamList.Add("--input_path") 257 | $ParamList.Add("`"$input_path`"") 258 | } 259 | if($testset -ne ""){ 260 | $ParamList.Add("--testset") 261 | $ParamList.Add($testset) 262 | } 263 | if($result_path -ne ""){ 264 | $ParamList.Add("--result_path") 265 | $ParamList.Add("`"$result_path`"") 266 | } 267 | if($accountForApp -ne ""){ 268 | $ParamList.Add("--accountForApp") 269 | $ParamList.Add($accountForApp) 270 | } 271 | if($applicationId -ne ""){ 272 | $ParamList.Add("--applicationId") 273 | $ParamList.Add($applicationId) 274 | } 275 | if($applicationSecret -ne ""){ 276 | $ParamList.Add("--applicationSecret") 277 | $ParamList.Add($applicationSecret) 278 | } 279 | if($applicationScope -ne ""){ 280 | $ParamList.Add("--applicationScope") 281 | $ParamList.Add("`"$applicationScope`"") 282 | } 283 | if($account_name -ne ""){ 284 | $ParamList.Add("--accountName") 285 | $ParamList.Add($account_name) 286 | } 287 | if($UserKey -ne ""){ 288 | $ParamList.Add("--token") 289 | $ParamList.Add($UserKey) 290 | } 291 | if($orchestrator_user -ne ""){ 292 | $ParamList.Add("--username") 293 | $ParamList.Add($orchestrator_user) 294 | } 295 | if($orchestrator_pass -ne ""){ 296 | $ParamList.Add("--password") 297 | $ParamList.Add($orchestrator_pass) 298 | } 299 | if($folder_organization_unit -ne ""){ 300 | $ParamList.Add("--organizationUnit") 301 | $ParamList.Add("`"$folder_organization_unit`"") 302 | } 303 | if($environment -ne ""){ 304 | $ParamList.Add("--environment") 305 | $ParamList.Add($environment) 306 | } 307 | if($timeout -ne ""){ 308 | $ParamList.Add("--timeout") 309 | $ParamList.Add($timeout) 310 | } 311 | if($out -ne ""){ 312 | $ParamList.Add("--out") 313 | $ParamList.Add($out) 314 | } 315 | if($language -ne ""){ 316 | $ParamList.Add("--language") 317 | $ParamList.Add($language) 318 | } 319 | if($traceLevel -ne ""){ 320 | $ParamList.Add("--traceLevel") 321 | $ParamList.Add($traceLevel) 322 | } 323 | if($disableTelemetry -ne ""){ 324 | $ParamList.Add("--disableTelemetry") 325 | $ParamList.Add($disableTelemetry) 326 | } 327 | if($attachRobotLogs -ne ""){ 328 | $ParamList.Add("--attachRobotLogs") 329 | $ParamList.Add("`"$attachRobotLogs`"") 330 | } 331 | if($repositoryUrl -ne ""){ 332 | $ParamList.Add("--repositoryUrl") 333 | $ParamList.Add("`"$repositoryUrl`"") 334 | } 335 | if($repositoryCommit -ne ""){ 336 | $ParamList.Add("--repositoryCommit") 337 | $ParamList.Add("`"$repositoryCommit`"") 338 | } 339 | 340 | if($repositoryBranch -ne ""){ 341 | $ParamList.Add("--repositoryBranch") 342 | $ParamList.Add("`"$repositoryBranch`"") 343 | } 344 | 345 | if($repositoryType -ne ""){ 346 | $ParamList.Add("--repositoryType") 347 | $ParamList.Add("`"$repositoryType`"") 348 | } 349 | 350 | if($projectUrl -ne ""){ 351 | $ParamList.Add("--projectUrl") 352 | $ParamList.Add("`"$projectUrl`"") 353 | } 354 | 355 | if($identityUrl -ne ""){ 356 | $ParamList.Add("--identityUrl") 357 | $ParamList.Add("`"$identityUrl`"") 358 | } 359 | 360 | 361 | 362 | 363 | #mask sensitive infos before loging 364 | $ParamMask = New-Object 'Collections.Generic.List[string]' 365 | $ParamMask.AddRange($ParamList) 366 | 367 | $secretIndex = $ParamMask.IndexOf("--password"); 368 | if($secretIndex -ge 0){ 369 | $ParamMask[$secretIndex + 1] = ("*" * 15) 370 | } 371 | $secretIndex = $ParamMask.IndexOf("--token"); 372 | if($secretIndex -ge 0){ 373 | $ParamMask[$secretIndex + 1] = $userKey.Substring(0, [Math]::Min($userKey.Length, 4)) + ("*" * 15) 374 | } 375 | $secretIndex = $ParamMask.IndexOf("--applicationId"); 376 | if($secretIndex -ge 0){ 377 | $ParamMask[$secretIndex + 1] = $applicationId.Substring(0, [Math]::Min($applicationId.Length, 4)) + ("*" * 15) 378 | } 379 | $secretIndex = $ParamMask.IndexOf("--applicationSecret"); 380 | if($secretIndex -ge 0){ 381 | $ParamMask[$secretIndex + 1] = ("*" * 15) 382 | } 383 | 384 | #log cli call with parameters 385 | WriteLog "Executing $uipathCLI $ParamMask" 386 | 387 | #call uipath cli 388 | & "$uipathCLI" $ParamList.ToArray() 389 | 390 | if($LASTEXITCODE -eq 0) 391 | { 392 | WriteLog "Done!" 393 | Exit 0 394 | }else { 395 | WriteLog "Unable to run test. Exit code $LASTEXITCODE" 396 | Exit 1 397 | } 398 | --------------------------------------------------------------------------------