Skip to content

Commit

Permalink
add python script to call bitrise API and start a build, configure ru…
Browse files Browse the repository at this point in the history
…ltor
  • Loading branch information
RoRoche committed May 3, 2020
1 parent 3780a55 commit cbce60d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
settings.xml
secrets/bitrise.txt
private_key.asc
public_key.asc
*.gpg
Expand Down
22 changes: 9 additions & 13 deletions .rultor.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
docker:
image: "g4s8/rultor-android"
env:
ANDROID_SDK_ROOT: /opt/android
image: "coala/rultor-python"
as_root: true
architect:
- RoRoche
install:
- "pip3 install requests"
decrypt:
settings.xml: "repo/settings.xml.asc"
pubring.gpg: "repo/pubring.gpg.asc"
secring.gpg: "repo/secring.gpg.asc"
bitrise.txt: "repo/secrets/bitrise.txt.asc"
release:
script: |
git commit --allow-empty -am "${tag}"
./gradlew -PnewVersion="${tag}" eoandroidconcurrency:clean
./gradlew -PnewVersion="${tag}" eoandroidconcurrency:assemble
./gradlew -PnewVersion="${tag}" eoandroidconcurrency:publishReleasePublicationToSonatypeRepository
./gradlew -PnewVersion="${tag}" eorest:clean
./gradlew -PnewVersion="${tag}" eorest:jar
./gradlew -PnewVersion="${tag}" eorest:publishReleasePublicationToSonatypeRepository
./gradlew closeAndReleaseRepository
TOKEN=$(cat /home/r/bitrise.txt)
python3 repo/scripts/startBitriseBuild.py --token ${TOKEN} --appSlug 4b269ce2e4a54a10 --workflowId deploy --gitTag ${tag}
49 changes: 49 additions & 0 deletions scripts/startBitriseBuild.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import sys
import argparse
import json
import requests

parser = argparse.ArgumentParser()
parser.add_argument(
"--token",
help="Bitrise Access Token"
)
parser.add_argument(
"--appSlug",
help="Application slug"
)
parser.add_argument(
"--workflowId",
help="The workflow ID of the build to start"
)
parser.add_argument(
"--gitTag",
help="The Git tag to consider"
)
args = parser.parse_args()

url = 'https://api.bitrise.io/v0.1/apps/' + args.appSlug + '/builds'
headers = 'Authorization: ' + args.token
data = {
"hook_info": {
"type": "bitrise",
},
"build_params": {
"tag": args.gitTag,
"workflow_id": args.workflowId
},
"environments": [
{
"mapped_to": "GIT_TAG",
"value": args.gitTag
}
]
}

response = requests.post(
url,
data = data,
headers = headers
)

assert response.status_code == 200, "Bitrise API returns a not OK status"
17 changes: 17 additions & 0 deletions secrets/bitrise.txt.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-----BEGIN PGP MESSAGE-----

hQEMA5qETcGag5w6AQgAsHdRD00aAv5aMnWaGB32cLeVh428FcfFMe2Qt7TwNehv
n2RhhHBa/AhfUMeBO/jhDjFajuELejd5O0vu1PRG6m07tQKlqRB3VLsaVdnxgOIX
ICNvv6+SsFue1m9QKuFmFN+vwPevbyUU7CFxEyQ7G+Unk/DVQ894RkfAiGDQzL3T
bcwt79ROxK2LUqE5SxRAuhRwk0FK6fO+mLozd0OCfHICVsMjc4xJ1GO6abHevwf8
6H+ql0X1jDWUJ2qs1+HeIahU7/2S3TmSlWsAcx27ku4pkLnqqY+HxNCujzRghz/2
YU7W0FwofV6oiAl2XHinFUotFly+bLtv6NQEXHuNvNLAggHjazqHmwbDhlYNwaYL
8MYi4vivUz3TCVQJLKLeTEVS7FYJWy9WQwyVkv63U++TfzWfmTJECZH4aFeTAg7j
jUH8C870Ru4sZj+lb/zCWAn28qC/MJH5e5ymtV38WZCuroGv5WKCqomX/6sHpOb+
WOZATK/L7w/aD/8L8+Iza/Wrv1qTaz0E2RIndBx8o3s/EVG0XHpUKKTZ9kRVT0X0
qFXVXEJq1BsoNwvIzpcPdy7QAWL+RigbpmjGD2oViFOzZ8jYPAfrBPodd5BGrZJ1
Qq8fGLScQhs8MXAkCsKKtxGnOSefhBdciVRIcMof+dRUq+4T6K4W+u4kaQZQwDrf
3Y7w3DVaBAq50lKmlspTvgc7t9j5j36sMDKUeQ/Hp16hGXXs3J52PdIaUOqMG1vf
FMCCEMvqzeyT9FHksdZAwFuK5QA=
=Oye5
-----END PGP MESSAGE-----

0 comments on commit cbce60d

Please sign in to comment.