# Deploying Android apk to hockeyapp

**URL:** <https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198>\
**Category:** Deployments\
**Created:** [December 17, 2015, 11:32pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198 "2015-12-17T23:32:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![circleuser1](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@circleuser1](https://discuss.circleci.com/u/circleuser1)\
**Post date:** [December 17, 2015, 11:32pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/1 "2015-12-17T23:32:50Z")

</div>

Anyone know the command to be used in circle.yml to deploy output of Android build (APK) to hockeyapp? I looked at the docs and forums but didn’t find a solution. Thanks!

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [December 18, 2015, 3:00am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/2 "2015-12-18T03:00:30Z")

</div>

This circle.yml code should do the trick:

```
dependencies:
  pre:
    - sudo gem install shenzhen
test:
  override:
    - ./scripts/add-key.sh
    - ipa build -c Distribution
    - ./scripts/remove-key.sh
deployment:
  hockey:
    branch: master
    commands:
      - ipa distribute:hockeyapp -m "circleci build" --token $HOCKEYAPP_TOKEN

```

ref: [http://mazyod.com/blog/2015/03/26/marry-circleci-to-hockey/](http://mazyod.com/blog/2015/03/26/marry-circleci-to-hockey/)

---

<div class="post-metadata">

**Author:** ![circleuser1](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@circleuser1](https://discuss.circleci.com/u/circleuser1)\
**Post date:** [December 18, 2015, 3:47pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/3 "2015-12-18T15:47:06Z")

</div>

Tried that but didn’t work. Ultimately ended up writing a custom deploy script that does curl upload to hockey. Thanks for the answer anyway!

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [December 18, 2015, 7:24pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/4 "2015-12-18T19:24:09Z")

</div>

Sorry I wasn’t able to help. Would you be willing to share your script? It might be helpful to others.

---

<div class="post-metadata">

**Author:** ![dmaltsiniotis](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dmaltsiniotis/32/816_2.png) [@dmaltsiniotis](https://discuss.circleci.com/u/dmaltsiniotis)\
**Post date:** [December 18, 2015, 8:55pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/5 "2015-12-18T20:55:50Z")

</div>

I also wasn’t able to use that method, and ended up rolling with my own script. Here’s what I did:

**circle.yml:**

```
deployment:
  develop:
    branch: develop
    commands:
      - ./deploy_dev.sh

```

**deploy\_dev.sh:**

```
curl \
-F "status=2" \
-F "notify=0" \
-F "ipa=@AppName/build/outputs/apk/appname-dev-debug.apk" \
-H "X-HockeyAppToken: $HockeyAppToken" \
https://rink.hockeyapp.net/api/2/apps/$AndroidAppId_Dev/app_versions/upload
```

---

<div class="post-metadata">

**Author:** ![circleuser1](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@circleuser1](https://discuss.circleci.com/u/circleuser1)\
**Post date:** [December 18, 2015, 9:51pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/6 "2015-12-18T21:51:14Z")

</div>

@drazisil The script posted above by @dmaltsiniotis is exactly what I ended up writing.

---

<div class="post-metadata">

**Author:** ![nellylam](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/nellylam/32/1518_2.png) [@nellylam](https://discuss.circleci.com/u/nellylam)\
**Post date:** [April 14, 2016, 8:41pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/7 "2016-04-14T20:41:17Z")

</div>

> [@dmaltsiniotis](#):
>
> -F “ipa=@AppName/build/outputs/apk/appname-dev-debug.apk” \

Where do you find the location of your apk on circleci?

---

<div class="post-metadata">

**Author:** ![rekhaagarwal](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@rekhaagarwal](https://discuss.circleci.com/u/rekhaagarwal)\
**Post date:** [February 20, 2017, 8:00am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/9 "2017-02-20T08:00:07Z")

</div>

I want to upload specific builds ( verified builds) of circle ci on Hockey not all . How it can be automated with the help of above scripts.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rekhaagarwal](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@rekhaagarwal](https://discuss.circleci.com/u/rekhaagarwal)\
**Post date:** [February 22, 2017, 9:24am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/10 "2017-02-22T09:24:06Z")

</div>

Thanks to dmaltsiniotis for the script. I am able to successfully upload my multiple android apks simultaneously to hockey.  
Here are the steps. Hope it will help others.

1. First we need to get below parameter value :  
(a) Hockey app token - hockey api token which you can get from hockey dashboard  
(b) hockey app id- hockey app channel id to which you want to upload

2. Add all above parameters as Environment variables in circle ci dashboard as below:  
HOCKEYAPP\_TOKEN  
AndroidFirstAppId  
AndroidSecondAppId

3. Go to your circle.yml file and add below code  
deployment:  
feature:  
branch: /deploy-.\*/  
commands:

4. add deploy\_dev.sh file at the same place with circle.yml:

curl   
-F “status=2”   
-F “notify=1”   
-F “ipa=@APK FULL PATH(projectname/build/outputs/apk/APK\_NAME”   
-H “X-HockeyAppToken: $HOCKEYAPP\_TOKEN”   
[https://rink.hockeyapp.net/api/2/apps/$AndroidFirstAppId/app\_versions/upload](https://rink.hockeyapp.net/api/2/apps/%24AndroidFirstAppId/app_versions/upload)  
curl   
-F “status=2”   
-F “notify=1”   
-F “ipa=@APK FULL PATH(projectname/build/outputs/apk/APK\_NAME”   
-H “X-HockeyAppToken: $HOCKEYAPP\_TOKEN”   
[https://rink.hockeyapp.net/api/2/apps/$AndroidSecondAppId/app\_versions/upload](https://rink.hockeyapp.net/api/2/apps/%24AndroidSecondAppId/app_versions/upload)

trigger build 🙂

I have one query in this process. for now this deployment will trigger when there is specified branch name or tag. is there any method in which we can mention in commit message that deployment should be taken or not

---

<div class="post-metadata">

**Author:** ![sreedevr](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/sreedevr/32/18051_2.png) [@sreedevr](https://discuss.circleci.com/u/sreedevr)\
**Post date:** [March 21, 2018, 8:46am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/11 "2018-03-21T08:46:33Z")

</div>

This thread helped me to setup both the circleci and hockeyapp for me and its working perfectly. But I wonder how I can send the build ID or the build number to hockey app from circleci as an extra information so that tester. Now I am not able to recognize which build was generated from which commit.

---

<div class="post-metadata">

**Author:** ![sreedevr](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/sreedevr/32/18051_2.png) [@sreedevr](https://discuss.circleci.com/u/sreedevr)\
**Post date:** [March 28, 2018, 12:55pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/12 "2018-03-28T12:55:36Z")

</div>

-F "notes=$CIRCLE\_BRANCH  
-F “repository\_url=$CIRCLE\_REPOSITORY\_URL”   
-F “build\_server\_url=$CIRCLE\_BUILD\_URL”   
-F “commit\_sha=$CIRCLE\_SHA1” \

This is how I figured out to pass on some kind of tags.

---

<div class="post-metadata">

**Author:** ![piyushgupta77](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@piyushgupta77](https://discuss.circleci.com/u/piyushgupta77)\
**Post date:** [June 15, 2018, 6:22am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/15 "2018-06-15T06:22:01Z")

</div>

Thanks halfer. Have provided formatted yaml file 🙂

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 15, 2018, 9:47am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/16 "2018-06-15T09:47:51Z")

</div>

Great stuff. Paste your [YAML here](http://yaml-online-parser.appspot.com/) - it looks like it does not validate. That’d need to be fixed and re-committed in your repo.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 15, 2018, 10:55am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/18 "2018-06-15T10:55:29Z")

</div>

You cannot run scripts directly unless they have an appropriate execute bit set, although it seems you have tried that, so it is odd that that did not work. However, you can make it easier just by calling them in a shell command:

```
sh ./deploy.sh
```

---

<div class="post-metadata">

**Author:** ![piyushgupta77](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@piyushgupta77](https://discuss.circleci.com/u/piyushgupta77)\
**Post date:** [June 15, 2018, 11:36am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/19 "2018-06-15T11:36:57Z")

</div>

Many thanks @halfer

my deploy script it running now. But I am getting error  
#!/bin/bash -eo pipefail  
sh ./deploy.sh  
curl: (26) couldn’t open file “app/build/outputs/apk/app-debug.apk”  
Exited with code 26

Below is my deploy.sh

```
curl \
-F "status=2" \
-F "notify=1" \
-F "ipa=@${2:-app/build/outputs/apk/debug/app-debug.apk}" \
-H "X-HockeyAppToken: <hockey-app-token>" \
https://rink.hockeyapp.net/api/2/apps/<app-id>/app_versions/upload

```

As mentioned in my previous post for 1 of 2 failing builds, 3 targets are executed as follows:

1. Spin up Environment
2. Checkout code
3. Deploy to hockey app

"Since while running “Deploy to hockey app” build target was not run till time and hence app-debug should not be available.

Any idea how can I solve this? Is it expected behavior to have 2 builds running on Circle CI(I believe that could be because I am now using workflows and deploy is dependent on build)

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 15, 2018, 11:42am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/20 "2018-06-15T11:42:19Z")

</div>

> [@piyushgupta77](#):
>
> curl: (26) couldn’t open file “app/build/outputs/apk/app-debug.apk”

I am guessing this is created in your `build` job, and you are wanting to make use of it in your `deploy` job. By default, each job gets a clean build container, so your artefact will have gone. I suspect you will benefit from Workspaces to preserve this directory - see the manual.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 15, 2018, 11:45am UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/21 "2018-06-15T11:45:30Z")

</div>

> [@piyushgupta77](#):
>
> ```
> - run:
> name: Chmod permissions #if permission for deploy Dependencies fail, use this.
> command: sudo chmod +x ./deploy.sh
> 
> ```

Ah, I just spotted why this did not work - it is in the wrong job. Any changes you make in a build job are not automatically preserved for other jobs in the same workflow. Although you could move this step to the other job (since you presumably do not need it for building) it is now redundant, so I would recommend removing it.

---

<div class="post-metadata">

**Author:** ![piyushgupta77](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@piyushgupta77](https://discuss.circleci.com/u/piyushgupta77)\
**Post date:** [June 15, 2018, 2:30pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/22 "2018-06-15T14:30:14Z")

</div>

Thanks @halfer for all your help. I have deployed my build successfully. 🙂

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 15, 2018, 2:31pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/23 "2018-06-15T14:31:59Z")

</div>

> [@piyushgupta77](#):
>
> I have deployed my build successfully

Excellent, and you’re welcome. Please do explain how you did so, for the benefit of future readers 🙂.

---

<div class="post-metadata">

**Author:** ![piyushgupta77](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@piyushgupta77](https://discuss.circleci.com/u/piyushgupta77)\
**Post date:** [July 12, 2018, 12:57pm UTC](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198/25 "2018-07-12T12:57:13Z")

</div>

Re posting working yaml

```
version: 2
references:
  save_workspace_artifacts: &save_workspace_artifacts
    store_artifacts:
      path: outputs/outputs/apk
  attach_workspace_artifacts: &attach_workspace_artifacts
    attach_workspace:
      at: outputs
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-25-alpha
    environment:
      JVM_OPTS: -Xmx3200m
    steps:
      - checkout
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
      - run:
         name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
         command: sudo chmod +x ./gradlew
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
# - run:
# name: Run Tests
# command: ./gradlew lint test
      - run:
          name: Build Code
          command: ./gradlew assembleDebug
      - store_artifacts:
          path: app/build/reports
          destination: reports
      - store_artifacts:
          path: app/build/outputs
          destination: apk
      - persist_to_workspace:
          root: app/build
          paths:
            - outputs
# - store_test_results:
# path: app/build/test-results
      # See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples
      
  deploy:
    docker:
      - image: circleci/node:latest
    steps:
      - checkout
      - *attach_workspace_artifacts
      # storing to be visible on api as an outcome of the last build
      - *save_workspace_artifacts
      - run:
          name: Deploy to hockey app
          command: sh ./deploy.sh
		  
workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master
```

[Next page](https://discuss.circleci.com/t/deploying-android-apk-to-hockeyapp/1198.md?page=2)
