How to change an app buildpack without having to push it with the code again
search cancel

How to change an app buildpack without having to push it with the code again

book

Article ID: 298186

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

In some cases, it may be critical to change the buildpack to a different version, but the app code is not at hand so "cf push" cannot be used for that purpose. For these cases, using the Cloud Controller API (CC API) can help.


Environment

Product Version: 1.10

Resolution

Get the app guid with "cf app <APP-NAME> --guid"

  • If using CC API v2, change the builpack with

    • cf curl -X PUT /v2/apps/<APP-GUID> -d '{ "buildpack": "<NEW-BUILDPACK>" }' 
      
      Eg cf curl -X PUT /v2/apps/e670c382-6054-435b-aa08-00c713ed7b14 -d '{ "buildpack": "java_buildpack_4.37"}' 

       

  • If using CC API v3, you can do

    • cf curl /v3/apps/<APP-GUID>  -X PATCH   -d '{
          "lifecycle": {
            "type": "buildpack",
            "data": {
              "buildpacks": ["<NEW-BUILDPACK>"]
            }
          }
        }' 

       

    1. E.g. cf curl /v3/apps/57e10d6a-8fa5-4f70-8967-5265d01aae40   -X PATCH   -d '{
          "lifecycle": {
            "type": "buildpack",
            "data": {
              "buildpacks": ["java_buildpack_4.37"]
            }
          }
        }' 

       

      Restage the app