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

Build API endpoints update: now returns additional infos (https://github.com/bitrise-io/devcenter/pull/155/files):

Hello @viktorbenei

I’m currently looking at the api, and i was wondering if it would be possible to get the dates in the same format?

I currently get 2 different iso standarts

    "triggered_at": "2017-09-15T09:33:37.782249Z",
    "started_on_worker_at": "2017-09-15T09:35:35Z",
    "environment_prepare_finished_at": "2017-09-15T09:36:51Z",
    "finished_at": "2017-09-15T09:39:26Z" 

As you see triggered_at have milliseconds after. Is it posible to remove them, so triggered_at matches the other 3 dates? :smile_cat:

Hey @kimdv

We unified the date formats in the response of the build endpoints. So now the triggered_at field doesn’t have the nanoseconds anymore. Thanks for the notice.

2 Likes

How do i calculate estimated time for build or progress percentage while the build is in progress?

Hi, currently progress percentage it is not possible directly from the API, you can only do it by using the same “math” as we do on our website: take the most recent successful build which triggered the same workflow as the current one does - its duration, the difference between its finished_at and environment_prepare_finished_at is the 100%.

4 Likes

We would really like to see the “Trigger build” endpoint. Any timeline on this one?

1 Like

@matthias.buchetics It’s on our roadmap but no ETA yet / not scheduled yet. For now the official solution is to use the “old” Build Trigger API: http://devcenter.bitrise.io/api/build-trigger/

Hi Viktor, i’m having problem with the endpoint “GET /apps/{APP-SLUG}”. It always comeback without return.

 {
    "message": "Not Found"
 }

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 http://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:

@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

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

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

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?

@revans Hey man, check our Bitrise client for Android - #19 by milosz

2 Likes

@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).

@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).

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

1 Like

Any time :wink:

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

1 Like

@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.

3 Likes