# Serverless Package Stage Agnostic Assistance

**URL:** <https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294>\
**Category:** Serverless Framework\
**Created:** [April 18, 2018, 4:48pm UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294 "2018-04-18T16:48:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmhalejr](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dmhalejr/32/1872_2.png) [@dmhalejr](https://forum.serverless.com/u/dmhalejr)\
**Post date:** [April 18, 2018, 4:48pm UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/1 "2018-04-18T16:48:13Z")

</div>

Hello! In regards to serverless package I am looking to create a CI pipeline that only builds once and leverages the artifact (json and zip) generated by serverless to deploy to each environment. My assumption was that the deployable would be environment agnostic. In my serverless.yaml I’ve defined out my stage entry as stage: ${env:STAGE} but after some digging I realized that by default serverless package defaults stage to dev so my serverless-state.json is outputting “stage”: “dev”

My dev stage is deploying correctly, but once I want to promote that same deployable it’s failing obviously. Is there something I’m doing wrong or incorrectly thinking about regarding serverless deployments? The only thing I’m opposed to currently regarding solution is just building and deploying in the same job.

Any help would be greatly appreciated! Thanks!

---

<div class="post-metadata">

**Author:** ![DavidWells](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/davidwells/32/201_2.png) [@DavidWells](https://forum.serverless.com/u/DavidWells)\
**Post date:** [April 18, 2018, 10:24pm UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/2 "2018-04-18T22:24:17Z")

</div>

What does your serverless.yml look like?

You can set the `stage` key under the `provider` block

---

<div class="post-metadata">

**Author:** ![dmhalejr](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dmhalejr/32/1872_2.png) [@dmhalejr](https://forum.serverless.com/u/dmhalejr)\
**Post date:** [April 19, 2018, 12:11am UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/3 "2018-04-19T00:11:40Z")

</div>

@DavidWells

Thanks for your prompt reply!

I went ahead and created a minimal reproducible repo for you to see a working example.

> **[GitHub - dmhalejr/serverless-package-minimal-example: Minimal Reproducible Repo](https://github.com/dmhalejr/serverless-package-minimal-example)**
>
> Minimal Reproducible Repo. Contribute to dmhalejr/serverless-package-minimal-example development by creating an account on GitHub.

My misunderstanding is just regarding the `sls package` command and why it defaults to `dev` even though I defined in the yml an environmental variable in the stage entry. My hope was that a environment agnostic package could be created and either `opt` or `env` variables could be leveraged to finalize the deploy like so:

`sls deploy --stage production --package /path/to/package`

Let me know if you need anything else!

---

<div class="post-metadata">

**Author:** ![dmhalejr](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dmhalejr/32/1872_2.png) [@dmhalejr](https://forum.serverless.com/u/dmhalejr)\
**Post date:** [April 29, 2018, 12:30pm UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/4 "2018-04-29T12:30:49Z")

</div>

Since this discussion a week (or so) ago I just made `sls deploy` handle both build and deploy of the artifacts. The issue I was running into seems… incorrect. I’ll await further clarification before removing my inquiry.

---

<div class="post-metadata">

**Author:** ![mmaglana](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mmaglana/32/6604_2.png) [@mmaglana](https://forum.serverless.com/u/mmaglana)\
**Post date:** [February 19, 2022, 1:31am UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/5 "2022-02-19T01:31:06Z")

</div>

@dmhalejr did you ever find a way to create environment-agnostic builds? I’m still wading through the docs and articles but haven’t found a way yet.

---

<div class="post-metadata">

**Author:** ![mmaglana](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mmaglana/32/6604_2.png) [@mmaglana](https://forum.serverless.com/u/mmaglana)\
**Post date:** [February 19, 2022, 1:41am UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/6 "2022-02-19T01:41:51Z")

</div>

There’s an open bug for it: [Allow to create reusable cross-stage deployment ready build artifacts · Issue #3528 · serverless/serverless · GitHub](https://github.com/serverless/serverless/issues/3528)

---

<div class="post-metadata">

**Author:** ![dmhalejr](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dmhalejr/32/1872_2.png) [@dmhalejr](https://forum.serverless.com/u/dmhalejr)\
**Post date:** [February 19, 2022, 2:52am UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/7 "2022-02-19T02:52:48Z")

</div>

Hey @mmaglana,

Thanks for checking out! Sadly I never found a way around this error and believe I still have my minimal viable project available.

I may take a stab this weekend in getting it up-to-date and checking with the latest version of serverless:

> **[GitHub - dmhalejr/serverless-package-minimal-example: Minimal Reproducible Repo](https://github.com/dmhalejr/serverless-package-minimal-example)**
>
> Minimal Reproducible Repo. Contribute to dmhalejr/serverless-package-minimal-example development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![krishay.baxter](https://avatars.discourse-cdn.com/v4/letter/k/51bf81/32.png) [@krishay.baxter](https://forum.serverless.com/u/krishay.baxter)\
**Post date:** [March 13, 2022, 10:40am UTC](https://forum.serverless.com/t/serverless-package-stage-agnostic-assistance/4294/8 "2022-03-13T10:40:21Z")

</div>

What does your serverless.yml look like?  
[Speed Test](https://testmyspeed.onl/)
