#前言
昨天我們看了一個 Bitbucket Pipeline 的範例
This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:lts
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- yarn install
- yarn build
branches:
develop:
- step:
name: build and test
caches:
- node
script: # Modify the commands below to build your repository.
- yarn install
- yarn build
- yarn test:cov
- step:
name: deploy with tag
script:
# - apt-get update
# - apt-get install -y unzip git
- echo "Clone all the things!"
- git tag -am "Tagging App for release ${BITBUCKET_BUILD_NUMBER}" v${BITBUCKET_BUILD_NUMBER}
- git push origin v${BITBUCKET_BUILD_NUMBER}
master:
- step:
name: build and test
caches:
- node
script: # Modify the commands below to build your repository.
- yarn install
- yarn build
- yarn test:cov
- step:
name: deploy with tag
script:
# - apt-get update
# - apt-get install -y unzip git
- echo "Clone all the things!"
- git tag -am "Tagging App for release ${BITBUCKET_BUILD_NUMBER}" release${BITBUCKET_BUILD_NUMBER}
- git push origin release${BITBUCKET_BUILD_NUMBER}
我們就開始來解析吧!
image: node:lts
代表的是要用什麼鏡像來執行,這邊用的是 node.js
的 LTS
版本
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- yarn install
- yarn build
這邊描述所有預設的 branches
都要做的事情,caches
代表使用 npm
的快取。
script
表示的是要執行的指令,這邊執行了 yarn install
與 yarn build
只要這兩個指令通過,就代表 Pipeline
成功了!
develop:
- step:
name: build and test
caches:
- node
script: # Modify the commands below to build your repository.
- yarn install
- yarn build
- yarn test:cov
- step:
name: deploy with tag
script:
# - apt-get update
# - apt-get install -y unzip git
- echo "Clone all the things!"
- git tag -am "Tagging App for release ${BITBUCKET_BUILD_NUMBER}" v${BITBUCKET_BUILD_NUMBER}
- git push origin v${BITBUCKET_BUILD_NUMBER}
這邊代表的是在 develop
分支下要執行的 Pipeline
,除了有 default
的一些指令外,還另外加了 yarn test:cov
,並且還會自行產生 Version Tag
,這個 Version Tag
會觸發後面的部署流程,這個我們明天繼續!
最後是 master
分支的工作。其實跟 develop
大同小異,只是 Version Tag
的命名方式不一樣而已!
- git push origin release${BITBUCKET_BUILD_NUMBER}
OK!我們今天介紹了整個 Bitbucket Pipeline
最基礎的用法,明天就讓我們來介紹如何觸發 Google Cloud Build
!