executing "cf-push" using cf-java-client

488 views Asked by At

I am very new to using cloud foundry. Currently, I am trying to automate the task of pushing an app to a target URL using the cloud foundry java client library but I am not being able to figure out how to push the manifest file ,i.e, how do i execute the command "cf push -f " using java client library ?

I am being able to login and view the list of spaces and organizations. I just need to push into an organization in the dev space.

Thanks in advance !

1

There are 1 answers

0
Daniel Mikusa On

For starters, you want to use the CloudFoundryOperations API. This is a higher level abstraction and mimics the behaviors of the cf cli. This is opposed to the CloudFoundryClient API which more closely mimics the raw underlying Cloud Foundry API.

The CloudFoundryOperations.pushManifest(..) method should do what you want. It takes a PushApplicationManifestRequest object.

You can use the builder directly to create one, or you can use the ApplicationManifestUtils.read(..) method. The read(..) method will read from a traditional cf cli manifest.yml file and you can use the Builder's methods like addAllManifests(..) or manifests(..) to add the ApplicationManifest object that you get from the call to read(..) to your PushApplicationManifestRequest object.

When you have the PushApplicationManifestRequest object build the way you want, you simply pass that through to CloudFoundryOperations.pushManifest(..).

For other's reference, there is a CloudFoundryOperations.push(..) method, if you don't want to use a manifest that one will work too. It functions roughly the same, but doesn't have the support for manifests.