#!/bin/bash

JOB_NAME='build-android-feature-replacexutils'

mkdir /data/download_android/${JOB_NAME}/apk -p
cd /data/download_android/${JOB_NAME}/apk/
#cp /data/jenkins_home/workspace/${JOB_NAME}/app/FirstHot.jks .


for i in /data/jenkins_home/workspace/${JOB_NAME}/app/build/outputs/apk/*/*/*
do 
  if [[ $i =~ ".apk" ]] 
  then 
    apkname=`basename $i`
    #jarsigner  -verbose -storepass tagtic2017 -storetype jks -keystore  FirstHot.jks  -signedjar "$apkname"  "$i" "FirstHot-Donews"
    \cp -r -f $i /data/download_android/${JOB_NAME}/apk/
  fi 
done

for i in `ls` 
do 
  base_name=${i%.*}
  #pngname=${basename##*_}
  if [[ $i =~ ".apk" ]]
  then
    if [[ $i =~ "qijian" ]]
    then
      /usr/bin/python /data/download_android/qr.py "http://122.13.78.219/${JOB_NAME}/apk/$i" "/data/download_android/${JOB_NAME}/$base_name.png"
      /usr/bin/python /data/download_android/qr.py "http://122.13.78.219/${JOB_NAME}/apk/$i" "/data/download_android/${JOB_NAME}/qijianRelease.png"
      echo "http://122.13.78.219/${JOB_NAME}/apk/$i" >> /data/download_android/${JOB_NAME}/download.txt
    else
      /usr/bin/python /data/download_android/qr.py "http://122.13.78.219/${JOB_NAME}/apk/$i" "/data/download_android/${JOB_NAME}/$base_name.png"
      echo "http://122.13.78.219/${JOB_NAME}/apk/$i" >> /data/download_android/${JOB_NAME}/download.txt
    fi
  fi
done
