# Deploying a package

## Introduction

Having created a package with a collection of process flows for deployment to one or more virtual environments, you can deploy it.&#x20;

Deploying a package adds all associated [flow versions](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/deploying-a-single-process-flow-to-a-virtual-environment/understanding-flow-versioning-for-virtual-environments) to a selected virtual environment. As part of the deployment, all process flow versions are [enabled](https://doc.wearepatchworks.com/product-documentation/virtual-environments/managing-virtual-environments-versions-and-flows/managing-virtual-environment-flow-deployments/disabling-or-enabling-a-process-flow-deployment-for-a-virtual-environment), so they will run in the virtual environment automatically, according to any defined [trigger settings](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/creating-a-master-process-flow/special-considerations-for-building-master-process-flows/special-considerations-for-building-master-process-flows-trigger-settings).

## Need to know

* You can deploy a given package to a virtual environment as many times as you need.
* If a [deployed configuration](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/deploying-the-configuration-for-a-virtual-environment) exists for the selected virtual environment, this will be used. Otherwise, the current `draft` configuration is used. Note that this behaviour differs from [deploying a single process flow via process flow settings](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/deploying-a-single-process-flow-to-a-virtual-environment), where only `deployed` virtual environments can be selected.&#x20;
* If you deploy a package to a virtual environment and the package includes a process flow that already exists in that virtual environment, the package takes precedence - the existing version becomes `inactive` and the package version is `deployed`. &#x20;
* When process flows are deployed via a package, they are [enabled](https://doc.wearepatchworks.com/product-documentation/virtual-environments/managing-virtual-environments-versions-and-flows/managing-virtual-environment-flow-deployments/disabling-or-enabling-a-process-flow-deployment-for-a-virtual-environment) automatically (i.e. they will run according to any [trigger shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/trigger-shape) settings). If you aren't ready for these deployments to be live, you can choose to deploy the package with `disabled` process flows.
* Process flows are associated with a package for deployment purposes only. After a flow version is deployed, it won't be affected by any subsequent actions taken with the package - for example, if a package is [removed](https://doc.wearepatchworks.com/product-documentation/virtual-environments/virtual-environment-packages/managing-packages/deleting-a-package), any associated flow deployments won't change.

## The steps

{% stepper %}
{% step %}
**Access virtual environment packages**

[Log in to the dashboard](https://app.wearepatchworks.com/virtual-environments) and select `virtual environments` | `packages` from the left-hand navigation menu.
{% endstep %}

{% step %}
**Find the required package**

Locate the package that you want to deploy (you can scroll the list, step through multiple pages, or search).
{% endstep %}

{% step %}
**Select the deploy option**

Click the ellipsis icon associated with the required package, then select the `deploy` option:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FyW2g15zA26oSLgNfhOhE%2Fdeploy%20package%202.png?alt=media&#x26;token=5d113ab2-7ac6-4dee-a1f3-29ec2ce0bb1d" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select a virtual environment**

Click in the `environment` field and select the required virtual environment(s) - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FJIDBJt5j0xag1mCmWlJs%2Fdeploy%20package%20to%20multi%20ves%201a.png?alt=media&#x26;token=951bdcb2-034a-4910-a54d-4f5128e25599" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Use check boxes to select one or more environments - or use the 'select all' checkbox to select all envrionments.
{% endhint %}

{% hint style="warning" %}
All flows in the associated package will be deployed to the selected environments. If the package includes a process flow for which a version already exists in the selected environment, the existing version in the virtual environment is replaced with the package version.&#x20;

If you're unsure what might be replaced in virtual environments as a result of this deployment, you can use the [compare](https://doc.wearepatchworks.com/product-documentation/virtual-environments/virtual-environment-packages/managing-packages/comparing-packages) option to clarify proposed updates.
{% endhint %}
{% endstep %}

{% step %}
**Add notes & confirm your selection**

Optionally, you can add notes for this deployment - after this, click the `review` button:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F8LPU3rg2tWTsFSoTfzgy%2Fdeploy%20package%204.png?alt=media&#x26;token=56fc6e43-2e11-4101-b7b4-fc4dd30e9723" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Review pending deployments**

Use the `review` panel to double-check flow versions in the selected package - for example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F5nXuwbqHiV5Xp1U82ELD%2Fdeploy%20package%205.png?alt=media&#x26;token=bd290c58-94fb-406c-80de-12c38d4e39ee" alt=""><figcaption></figcaption></figure>

If necessary, you can:

* Use `remove` buttons to remove associated flows from this package
* By default, process flows are `enabled` when deployed via a package. You can use the `disable flows` toggle option to deploy flows as `disabled`, so they exist in the target environment but do NOT run automatically.&#x20;

{% hint style="info" %}
The contents of a package cannot be changed after deployment.
{% endhint %}
{% endstep %}

{% step %}
**Deploy the package**

When you're satisfied that the content of the package is correct, click the `deploy` button - for example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F2YpaxnDs2PD0KpkL0We6%2Fdeploy%20package%205e.png?alt=media&#x26;token=0d9c58a8-6d6a-4288-84c0-fe1f1093fece" alt=""><figcaption></figcaption></figure>

All flow versions in the package are deployed to the selected virtual environment, and you're returned to the list of packages.&#x20;
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/virtual-environments/virtual-environment-packages/managing-packages/deploying-a-package.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
