Creating a Build

Bitbar Build service is currently an API only service. The following steps guide you how to create your first build on the service.

Get All Jobs

To get started with build, you need to have a builder dedicated for you to use. Please handle this with Bitbar sales. Also you need to get your API_KEY from your account settings in Bitbar Cloud.

$ curl -H Accept:application/json -u $BITBAR_BUILD_TOKEN: https://<customer cloud URL>/cloud/api/v2/me/jobs | python -m json.tool

Step 1: Create a Job

You’ll need to have an existing Jenkinsfile that defines the details of your build. Here the Jenkinsfile is in the @android-job file that’s uploaded to the build project.

Here’s how the android-job file looks like:

name=nameOfBuild&content=try {
  node("macos10.12.6") {
    stage("Preparation") {
      sh("curl -o in.tar '$BB_INPUT_FILE_SET_URL'")
      sh("tar -xzvf in.tar")

    stage("Build") {
      dir('BitbarSampleApp') {
        sh('./gradlew build')

    stage("Result") {
      sh("curl -X PUT '$BB_OUTPUT_FILE_SET_URL' --upload-file BitbarSampleApp/app/build/outputs/apk/app-debug.apk")

catch (exc) {

finally {
  node() {
    curl -X POST $BB_CLOUD_URL/api/v2/users/$BB_USER_ID/jobs/$BB_JOB_ID/builds/$BB_BUILD_ID?buildNumber=$BUILD_NUMBER \
    -u '$BB_API_KEY:'

In the above name=nameOfBuild&content= is not part of the Jenkinsfile but used here to allow Curl to upload the file to you builder. Create a new build job by uploading the above build to the builder.

$ curl -X POST -H Accept:application/json -u $BITBAR_BUILD_TOKEN: https://<customer cloud URL>/cloud/api/v2/me/jobs --data-binary @android-job | python -m json.tool

Make note of the id in the response message as it is needed in next steps. Let’s define it as $BITBAR_BUILD_JOB_ID for later use.


Step 2: Upload File

$ curl -X POST -H Accept:application/json -u $BITBAR_BUILD_TOKEN: https://<customer cloud URL>/cloud/api/v2/me/files -F "file=@BitbarSampleApp.tar.gz" | python -m json.tool

Again keep somewhere the file id from the response and make it into an environment variable to be used by later steps.


Step 3: Start Job Based on ID

$ curl -X POST -H Accept:application/json -u $BITBAR_BUILD_TOKEN: https://<customer cloud URL>/cloud/api/v2/me/jobs/$BITBAR_BUILD_JOB_ID/builds?fileId=$BITBAR_BUILD_FILE_ID | python -m json.tool

Again the build id is stored as environment variable so, polling for results is easier.

Step 4: Get Result

$ curl -H Accept:application/json -u $BITBAR_BUILD_TOKEN: https://<customer cloud URL>/api/v2/me/jobs/$BITBAR_BUILD_JOB_ID/builds/$BITBAR_BUILD_ID/output-file-set/files | python -m json.tool