# Rebuild with latest commit

**URL:** <https://forum.buildkite.community/t/rebuild-with-latest-commit/1552>\
**Category:** Features Requests\
**Created:** [May 4, 2021, 4:17pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552 "2021-05-04T16:17:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrar](https://avatars.discourse-cdn.com/v4/letter/i/51bf81/32.png) [@ibrar](https://forum.buildkite.community/u/ibrar)\
**Post date:** [May 4, 2021, 4:17pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/1 "2021-05-04T16:17:56Z")

</div>

One of the actions I repeat the most is:  
- Make some changes on a branch  
- Open a previous build on the same branch, and copy the environment variables I entered last time.  
- Make a new build, exactly the same except using the latest commit (HEAD).

It’s exactly the same build, except using HEAD instead of an older commit. Rebuild right now correctly reproduces the build when clicking the _Rebuild_ button, but it would be really good to have another button for “rebuilding” with the latest commit.

Maybe it can appear only if the build commit is no longer HEAD.

Thanks for your time!

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [May 6, 2021, 4:49pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/2 "2021-05-06T16:49:53Z")

</div>

Hi @ibrar!

Welcome to the community!  
We have passed this onto our product team for their consideration.

Thanks for contributing!  
Cheers,

---

<div class="post-metadata">

**Author:** ![jod](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@jod](https://forum.buildkite.community/u/jod)\
**Post date:** [October 19, 2021, 9:02am UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/3 "2021-10-19T09:02:32Z")

</div>

I’ve been wishing for something like this recently as well. We have a view pipelines with a input steps that need a few different things entered and selected.

It’s a minor irritation but it it would be nice not to have to repeat the same steps over and over when we just want to pick to the latest commit and re-use everything else exactly as before.

---

<div class="post-metadata">

**Author:** ![jmenestr](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/jmenestr/32/1099_2.png) [@jmenestr](https://forum.buildkite.community/u/jmenestr)\
**Post date:** [June 24, 2022, 4:57pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/4 "2022-06-24T16:57:06Z")

</div>

Curious if there’s an update on this? Of if there’s a workaround solution to enable this sort of behavior?

---

<div class="post-metadata">

**Author:** ![sushant](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sushant/32/1211_2.png) [@sushant](https://forum.buildkite.community/u/sushant)\
**Post date:** [March 20, 2023, 6:02pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/5 "2023-03-20T18:02:53Z")

</div>

Is there any work around or plugins

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [April 5, 2023, 6:01pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/6 "2023-04-05T18:01:33Z")

</div>

Hey folks!

In case you didn’t see it, now when you click on the Rebuild button you have new options:

![image](https://us1.discourse-cdn.com/flex016/uploads/buildkite1/original/2X/2/22ab7e0abd0e6438354c86fbcb4d9f8d3eb3c08a.png)

---

<div class="post-metadata">

**Author:** ![ibrar](https://avatars.discourse-cdn.com/v4/letter/i/51bf81/32.png) [@ibrar](https://forum.buildkite.community/u/ibrar)\
**Post date:** [April 19, 2023, 3:29pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/7 "2023-04-19T15:29:52Z")

</div>

Hi Paula!

This is a nice feature. Its not useful to me, because I still have to copy the custom environment variables I entered in this build.

Any way to add this? So we can rebuild this branch… but with the env vars I used in this build (otherwise its not really a rebuild… its just another build).

Thank you!

---

<div class="post-metadata">

**Author:** ![karen.sawrey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/karen.sawrey/32/1188_2.png) [@karen.sawrey](https://forum.buildkite.community/u/karen.sawrey)\
**Post date:** [April 19, 2023, 4:29pm UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/8 "2023-04-19T16:29:38Z")

</div>

Hello, @ibrar! Welcome back to the Community!

What you are trying to do should be possible. Can you please send an URL to the build where you’re seeing an issue to [support@buildkite.com](mailto:support@buildkite.com)?  
Best!

Karen

---

<div class="post-metadata">

**Author:** ![bretta](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@bretta](https://forum.buildkite.community/u/bretta)\
**Post date:** [March 18, 2024, 6:42am UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/9 "2024-03-18T06:42:35Z")

</div>

There is a way you can simulate this in a convenient way. Add code in a command step like this:

```auto
buildkite-agent annotate '<a href="..." target="_blank">Initiate rebuild with latest</a>' --context ctx-rebuild

```

For the **href** embed a URL which will launch a **New Build** with environment variables pre-populated. The link should look a similar to this:

```auto
https://buildkite.com/your-org/your-pipeline#new?message=Rebuild%20with%20latest&branch=master&commit=HEAD&env=NAME_1%3DVALUE_1%0ANAME_2%3DVALUE_2%0A

```

Getting the escaping right is fiddly, but then it works quite well…

 ![new_build](https://us1.discourse-cdn.com/flex016/uploads/buildkite1/original/2X/f/f69fd5fad099d25a3fc715e11172ede2beeb8c02.png)

---

<div class="post-metadata">

**Author:** ![tomwatt](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tomwatt](https://forum.buildkite.community/u/tomwatt)\
**Post date:** [March 18, 2024, 9:42am UTC](https://forum.buildkite.community/t/rebuild-with-latest-commit/1552/10 "2024-03-18T09:42:13Z")

</div>

Hey @bretta

Welcome to the Buildkite Community Forums!

Thanks for sharing that trick with the annotations!

Cheers!

Tom
