通过电子邮件发送 *.apk。比特桶管道

Send * .apk by email. Bitbucket pipelines

如何发送android apk 到邮箱?比特桶管道。我正在 bitbucket-pipelines.yml 使用 slack。

- curl -F file=@"./app/build/outputs/apk/debug/app-debug.apk" -F channels=${SLACK_CHANNEL} -F token=${SLACK_TOKEN} https://slack.com/api/files.upload

按如下方式更正文件。

- curl -F file=@"./app/build/outputs/apk/$FILE_NAME" -F channels=${SLACK_CHANNEL} -F token=${SLACK_TOKEN} https://slack.com/api/files.upload

完整的 YML:

image: uber/android-build-environment:latest

pipelines:
  default:
    - step:
        script:
            # Grab the Android Support Repo which isn't included in the container
            - echo y | android update sdk --filter "extra-android-m2repository" --no-ui -a 
            - mkdir "${ANDROID_HOME}/licenses" || true
            - echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
            - echo "d56f5187479451eabf01fb78af6dfcb131a6481e" >> "${ANDROID_HOME}/licenses/android-sdk-license"
            - ./gradlew assembleDebug
            - . ./setup_export.sh
            ##########  UPLOAD APK TO SLACK #CHANNEL ##########
            # Setup the following enviroment variables on bitbucket pipelines  & 
            # SLACK_TOKEN - Obtain this token from: https://api.slack.com/custom-integrations/legacy-tokens
            # SLACK_CHANNEL - Channel name to upload the file. 
            - curl -F file=@"./app/build/outputs/apk/$FILE_NAME" -F channels=${SLACK_CHANNEL} -F token=${SLACK_TOKEN} https://slack.com/api/files.upload
            ##########  UPLOAD A CHANGELOG POST TO SLACK #CHANNEL ##########
            - curl -F content="---Uploaded by bitbucket pipelines, Pending manual edit---" -F filetype=post -F title="$FILE_TITLE CHANGELOG $BUILD_DATE" -F channels=${SLACK_CHANNEL} -F token=${SLACK_TOKEN} https://slack.com/api/files.upload

"setup_export.sh" 文件。

#!/usr/bin/env bash
LATEST_APK=$(ls -lrt ./app/build/outputs/apk/*.apk | tail -1 | awk -F" " '{ print  }') #Pick the latest build apk. 
FILE_NAME=$(basename $LATEST_APK .apk)".apk" 
BUILD_DATE=`date +%Y-%m-%d` #optional -- For changelog title. 
FILE_TITLE=$(basename $LATEST_APK .apk) #optional -- For changelog title. 

功劳归于以下用户。

https://github.com/kigen/bitbucket-pipelines-android