Upload/Update XSP application to Bluemix through Cloud Foundry API - ibm-cloud

I'm using Cloud Foundry API to modify apps on IBM Bluemix.
I got oauth key and succeeded in calling simple REST requests, like v2/apps.
However, as I want to update XSP application I need to send a nsf file to bluemix.
I tried to use /v2/apps/:guid request, but according to documentation I can only send application parameters, but I cannot send whole application file.
Is there an endpoint to do that?

There is also an API to Upload the bits for an App, but if my understanding is correct what you are asking is basically to emulate a cf push via REST API. Please note that cf push is complex and is not something that is recommended recreating via API on Cloud Foundry. I don't know what your requirements are, but I'd suggest you to use cf push to do that. Anyway if you want more information on what are the steps it performs (from an high level perspective) you can take a look here. I suggest you also to see this Github Cloud Foundry issue where the user is trying to programmatically recreate the cf push.

Related

How to connect Google Cloud Source Repo with Codemagic?

Codemagic is a build service for flutter applications it has built in support for bitbucket, github, etc. However it also supports linking repositories from other sources. To set this up you they ask you for a specificish format. URL should be in the following format: https://example.com/username/repo.git or git#example.com/username/repo.git.
I'm trying to figure out how to provide a url for my google cloud source repo in this format. I've tried this https://source.developers.google.com/p/[project-name]/r/[repo-name/ but then it complains about credentials. If I use the 'git#source.developers.google.com/.....' format I get an option to load an ssh key to authenticate and that passes verification but it doesn't correctly register/see the repo at the endpoint so something is off.
Anyone ever done this before. I've seen something about signed urls with google cloud and thought maybe I could use the https: format both make a signed url though everything i've seen with signed urls has to do with cloud storage and not cloud source.
I was able to add Google Cloud Source Repo to Codemagic using next link
ssh://mikhail#example.com#source.developers.google.com:2022/p/woven-voyage-xxxxx/r/test
You need also register your SSH key https://source.cloud.google.com/user/ssh_keys?register=true
In addition to #Mikhil Tokarev's answer,
You need to add a webhook manually after adding the Google source repository.
Please see my answer detailed instruction in this thread https://stackoverflow.com/a/63362923/11082769

Is there any way to trigger a Google Cloud build ONLY when a merge request is accepted on a specific branch?

Basically I just started using Google Cloud and I'm looking for a way to trigger a deployment ONLY when a pull request is accepted on a distant github repository.
I'm currently using the google "Cloud Build Trigger" to execute my 'cloudbuild.yaml' as soon as a push is detected on my master branch, but simply attempting a merge request seems to trigger my build process.
This is troublesome as a merge request will be reviewed by peers and I don't want my cloud application to rebuild if the merge request is to be denied after being reviewed.
As this feature is still in beta, I assume this is not supported yet and that there is a better way to handle such task, but when I heard of the trigger feature it seemed like the most straightforward way to connect my github repository to the build process on google cloud. Anyway, hope someone had to face this issue or can help me figure this one out.
Thanks !
Based on the documentation, Cloud Build triggers currently only support changes pushed to the build source (a remote Github repo in this case). There doesn't seem to be a way to distinguish between a merge resulting from a (remote) pull request or a local one from the Google Cloud Console GUI.
However, you are not without options. One alternative is to leverage Github's PullRequestEvent Webhook and deploy a GAS Web App or Cloud Function to serve as a web-hook endpoint. The GAS Web App or Cloud Function could then parse the event payload for GitHub's PullRequestEvent and if the pull request is closed and merged then you call the REST API for the Cloud Build service to start your build.

Pushing liberty app + server to Bluemix

I want to deploy a liberty application along with server config to Bluemix, I found these options listed in the documentation
https://console.bluemix.net/docs/runtimes/liberty/optionsForPushing.html#options_for_pushing
My question is should we be pushing the app + server always to keep the server config, or it like push app + server for the first time and subsequent pushes can only contain app files ? will the server config be retained?
You need to push the app + server every time.
There are a number of ways to deploy Liberty on the IBM Cloud - the recommended place to get started is on the App Service console:
https://console.bluemix.net/developer/appservice/starter-kits
The documentation has options for Kubernetes / CF Deployment to the Cloud and recommend using the IBM Cloud Dev CLI tooling which containerizes your app to run locally and gives you the option to push the image up when you're ready.
In addition, starter kits set up an example of how you can incorporate DevOps into your app. When you make changes from your Git Repo, it will trigger a hook which will run the app through your testing pipelines, and deploy it to the cloud.
The idea of using containers is so you can package your application with a consistent, reproducible environment, so you can orchestrate and scale your application when necessary.

Cloud foundry push from URL

There is option to push the application from git URL or any URL
using the CF Client (I mean via code) ?
Here there is documentation how to push from path
http://cli.cloudfoundry.org/en-US/cf/push.html
Neither the cf CLI, nor the Java client, nor the Cloud Controller API currently accept a git URL (or any other URL) to download the application bits into Cloud Foundry.
The --path option on cf push only accepts paths on your local filesystem.
If we were to support this (the topic has come up once or twice), it may make most sense for the Cloud Controller to expose an API for it, so that it can be supported by all CF clients in the same way. With this approach, CF can also be smarter about updates: it can check the git sha to know whether new bits need to be downloaded.
An issue with the current APIs for the CLI is that the CLI would first need to download the app bits from the URL and then upload it to CF, which seems inefficient. It would not be any faster than git clone https://github.com/example/app && cf push myapp -p app (apart from saving you a handful of keystrokes).
As far as I am aware cf client does not support direct deployment via code relying on CI/CD systems for this.
Some helpful links for research and discuss it:
Project manager/lead for CF CLI project - Dies Köper
( https://www.cloudfoundry.org/projects/ -> CLI )
#cli on cloudfoundry.slack.com
Tracker on https://www.pivotaltracker.com/n/projects/892938

Adding custom status page to Jenkins instance

I want to use the REST API that comes with Jenkins to generate a status page which shows all my projects, the environments they're currently deployed to, latest build versions etc.
Jenkins provides a nice REST API to expose this info however consuming the service is limited by cross domain restrictions. I have looked briefly at creating a CORS filter for my Jenkins instance but its overkill for what I'm trying to achieve.
Can someone tell me if its possible to modify my Jenkins WAR (instance) and add some HTML which i can then modify to call the RESTful endpoints? Ideally i want something whereby i can simply navigate to http://myjenkins/project-status and see the required information.
I assume your status page has some Javascript executing XMLHttpRequests. You could drop your status page files into $JENKINS_HOME/userContent directory on the master. This way they are served by Jenkins and should be able to access Jenkins REST APIs.