Bitrise.io API v0.1 (Work In Progress)

api
#70

Hi @ipirangamobile,

In general I’d suggest you to:

  1. First try to call https://api.bitrise.io/v0.1/me to make sure that you did set the Authentication infos correctly
  2. After this call https://api.bitrise.io/v0.1/me/apps to get the list of the apps you can access. You can find the “slugs” in that list
  3. Then you can call https://api.bitrise.io/v0.1/apps/SLUG (replace SLUG with the actual slug of the app) to get infos about that specific app.

If this wouldn’t help please create an #issues report at https://discuss.bitrise.io/c/issues/website-issues

Please include the whole API call in it, e.g. the curl call you tried; every parameter except the Auth info / access token, so that we can help as fast as possible :slight_smile:

Of course if you have any questions just let us know! :wink:

0 Likes

#71

@viktorbenei,
I was use the “postman” for request this endpoints, and because of some thing that i forgot this don’t worked on the third. Now i used the curl as recommended on doc and work perfectly. I imported this command for Postman and this worked also.

In my next post about issues, i will post on correct place, sorry.

Thanks for your help.

1 Like

#72

No problem at all @ipirangamobile, and I’m glad to hear it worked :blush:

0 Likes

#74

Hello @viktorbenei - I started investigating the API for use in a internal tool to help my QA team find and install builds from different environments. I found that the API, as it stands today, has almost everything I would need to craft such a tool except one thing. For iOS builds when I pull a adhoc build then grab the ipa artifact I see the download URL. It appears I can’t just open that download URL in safari to have the IPA install. I know if I were to open the build on bitrise.io from the phone I can hit a download button and it installs the app. Is there a way to do something like this using the API that I might be missing?

Ideally I want to build out a small mobile application for internal use only that pulls builds and lets my internal users install them directly with little hassle.

1 Like

#75

Hey @viktorbenei

This may be a stupid question, but I was wondering if it’s possible to get project’s “building” status at top level (without looking at the builds)

I’m currently building a mobile client for iOS, inspired by the BItrise Unofficial for Android. The main page shows a list of projects for a user, and I’d like to show whether the last build on a given project has failed or succeeded without looking through the build list (as that would mean making another API call and slowing things down)

I can see that the JSON object for an app has a field called “status”, but for my projects it seems to always have the value of “1”, so I’m guessing it represents something else.

What would be the recommended approach with the current API?

0 Likes

#76

@revans Hey man, check our Bitrise client for Android

2 Likes

#77

@Alexei query the builds of the project with limit=1 to get only the latest one if you need that information, right now there’s no way to get it directly on project level. The bitrise.io dashboard does the same:

  1. first it requests the projects / project list
  2. then once the list is loaded it queries the status of the projects

You can use other query params as well if you’d want to get the last non PR build for example, or if you want to query a specific branch’s status (latest build on the branch).

0 Likes

#78

@revans alternatively you can open the public_install_page_url property’s value in mobile safari, which is a property of the artifact if a public install page is available (https://devcenter.bitrise.io/api/v0.1/#patch-appsapp-slugbuildsbuild-slugartifactsartifact-slug).

0 Likes

#79

@viktorbenei that is exactly what I did to make this work. Thanks!

1 Like

#80

Any time :wink:

0 Likes

#81

Thanks! :slight_smile: that’s the solution I ended up going with.

1 Like

#82

@viktorbenei I’m trying to set up a pipeline that will upload a new version of our bitrise.yml file but the way the API is currently set up is extremely cumbersome.

The curl statement at the moment expects a json object with a single key “app_config_datastore_yaml” and the entire bitrise.yml contents as value. This curl request looks like this:

curl -X POST -H 'Authorization: token THE-ACCESS-TOKEN' 'https://api.bitrise.io/v0.1/apps/APP-SLUG/bitrise.yml' -d '{"app_config_datastore_yaml":"app:\n  envs:\n  - BITRISE_PROJECT_PATH: sample-apps-osx-10-12.xcodeproj\n    opts:\n      is_expand: false\n  - BITRISE_SCHEME: sample-apps-osx-10-12\n    opts:\n      is_expand: false\ndefault_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git\nformat_version: 1.3.1\ntrigger_map:\n- push_branch: '*'\n  workflow: primary\n- pull_request_source_branch: '*'\n  workflow: primary\nworkflows:\n  deploy:\n    steps:\n    - activate-ssh-key@3.1.1:\n        run_if: '{{getenv \"SSH_RSA_PRIVATE_KEY\" | ne \"\"}}'\n    - git-clone@3.4.2: {}\n    - script@1.1.3:\n        title: Do anything with Script step\n    - certificate-and-profile-installer@1.8.4: {}\n    - xcode-test-mac:\n        inputs:\n        - project_path: $BITRISE_PROJECT_PATH\n        - scheme: $BITRISE_SCHEME\n    - xcode-archive-mac@1.4.0:\n        inputs:\n        - project_path: $BITRISE_PROJECT_PATH\n        - scheme: $BITRISE_SCHEME\n    - deploy-to-bitrise-io@1.2.9: {}\n  primary:\n    steps:\n    - activate-ssh-key@3.1.1:\n        run_if: '{{getenv \"SSH_RSA_PRIVATE_KEY\" | ne \"\"}}'\n    - git-clone@3.4.2: {}\n    - script@1.1.3:\n        title: Do anything with Script step\n    - certificate-and-profile-installer@1.8.4: {}\n    - xcode-test-mac@1.1.0:\n        inputs:\n        - project_path: $BITRISE_PROJECT_PATH\n        - scheme: $BITRISE_SCHEME\n    - deploy-to-bitrise-io@1.2.9: {}\n"}'

The problem with this approach is that if you have a very extensive build process, this one liner becomes very hard to generate (think escaping characters within script steps)

I would propose to simplify this and allow the API users to just call the API as follows:

curl -X POST
  -H 'Authorization: token THE-ACCESS-TOKEN'
  https://api.bitrise.io/v0.1/apps/APP-SLUG/bitrise.yml
  --data-binary @bitrise.yml

This way the users can just upload the yaml file exactly as it is expected, and there is no need to manipulate the contents of the file to fit into a curl statement.

1 Like

#83

@viktorbenei Am I missing something or is the documentation on https://devcenter.bitrise.io/api/v0.1/ very incomplete and half-hearted at the moment? What I mean is this:

POST /apps/register ⚓

Add a new application
Example curl request ⚓

curl -H 'Authorization: token THE-ACCESS-TOKEN' 'https://api.bitrise.io/v0.1/apps/APP-SLUG' -d '{"provider":"github","is_public":false,"repo_url":"git@github.com:api_demo/example-repository.git","type":"git","git_repo_slug":"example-repository","git_owner":"api_demo"}'

Example response ⚓

{
  "status": "ok",
  "slug": "022d8a3124f1225d"
}

This is all information there is for the “new app” API endpoint. The data I need to send is totally undocumented, there’s only an example. What I’m missing at least:

  • [ ] A short description for each request parameter.
  • [ ] All possible values for enum cases.

For example, I have no idea how to setup a new project which is hosted on a self-hosted GitLab server. What’s the right value for provider? What’s the git_owner? And on registering webhook, the example doesn’t even include any sent data – how does it work, then? I have do find these things out through trial and error now.

Also it’s totally unclear to me how the entire app creation process works given there are separate API endpoints for register-ssh-key, register-webhook and app/APP-SLUG/finish … will I have to wait and check some status until the scanner has completed? What if the scanner finds errors, how do I get them?

A complete documentation for the currently existing APIs would be very helpful!

0 Likes

#84

I have done some digging by now and managed to find out some stuff. When I try to finish the creation process though, I get an internal server error. Specifically this is what I’m sending:

Request to 'https://api.bitrise.io/v0.1/apps/<SOME-SLUG>/finish' failed.
Request body:
{"project_type":"ios","envs":{},"organization_slug":"<SOME-SLUG>","mode":"manual","stack_id":"osx-xcode-edge"}

The response is this:

{"status":500,"error":"Internal Server Error"}

Since it’s a 500 status code, there must be an issue on the backend side…

0 Likes

#85

@gergelybekesi any suggestion? :thinking:

0 Likes

#86

Hi @viktorbenei!
It seems there is a new status for builds (status 4, “abordted-with-success”), right? Any reason why it does not appear on the documentation?
Unfortunately this makes my iOS app crash :frowning_face:

0 Likes

#87

Indeed we introduced that a while ago and missed to add it to the docs, sorry @ghislainfrs - I’ll create a card for the docs team to update it!

2 Likes

#88

Can anyone provide me a way to assign the path of my profile and certificate which is already in my cloned code to bitrise.(using git)
right now, i am giving
{“mapped_to”:"$BITRISE_PROVISION_URL",“value”:“file://./profile/bitdist.mobileprovision | file://./profile/bitdev.mobileprovision”,“is_expand”:true}
but it is not working…

0 Likes

#89

Hey @jamitlabs

Sorry for the late response, I’ve updated the documentation on DevCenter, there was an issue in the description and also I’ve added some more details :slight_smile: Here you can find the documentation for the finish endpoint, the issue was that the description mentioned config_id field in the request body, however it has to be called config. Sorry for the inconvenience!

0 Likes

#90

Hi @viktorbenei, have you got more info about « Trigger Build » ? Indeed there is a solved FR which seems to be related or maybe I misunderstand something… :face_with_monocle: Was there any rollback ? Thanks.

0 Likes