-
Notifications
You must be signed in to change notification settings - Fork 177
/
.travis.yml
23 lines (23 loc) · 1.26 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
language: node_js
node_js:
- "12"
install:
- npm install
script:
- npm test
- if [ $TRAVIS_PULL_REQUEST == false ]; then npm run package; fi
after_success:
- SHA01=$(echo $TRAVIS_COMMIT | cut -c1-8)
- for f in package/*.zip; do mv "$f" "`echo $f | sed s/.zip/.$TRAVIS_BRANCH.$SHA01.zip/`"; done
- ARTIFACT_FILENAME=package/$(ls package | grep .zip)
# Delete last build from bitbucket
- maxAvailableBuilds=5
- builds=$(curl -X GET https://api.bitbucket.org/2.0/repositories/thomaschampagne/elevate-ci-builds/downloads?pagelen=100 | awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'name'\042/){print $(i+1)}}}' | tr -d '"' | grep zip | sed -e 's/^[ \t]*//' )
- buildCount=$(echo $builds | tr ' ' '\n' | grep -c 'zip')
- if [ $buildCount -ge $maxAvailableBuilds ]; then lastBuild=$(echo $builds | tr ' ' '\n' | tail -n1); echo Removing old $lastBuild; curl -u "$BITBUCKET_USERNAME:$BITBUCKET_PASSWORD" -X DELETE https://api.bitbucket.org/2.0/repositories/thomaschampagne/elevate-ci-builds/downloads/$lastBuild; fi
# Push the new one to bitbucket
- curl -u "$BITBUCKET_USERNAME:$BITBUCKET_PASSWORD" -X POST https://api.bitbucket.org/2.0/repositories/thomaschampagne/elevate-ci-builds/downloads --form "files=@$ARTIFACT_FILENAME"
branches:
only:
- master
- develop