XSGGT
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: GCP Cloud Build 介面介紹 tags: GCP # 簡報的標籤 --- ## 進入 Cloud Build 可以看到幾個功能 - 資訊主頁:觸發條件的一些基本資訊 - 紀錄:觸發條件成功狀況基本資訊和過程 - 觸發條件:觸發條件設定 - 設定:權限設定 ![](https://i.imgur.com/GyfoaPr.png) ## 一、設定:設定帳戶權限,EX:想要佈署在 GKE 就需要打開 Kubernetes Engine 權限,設定前要先到紀錄打開 API 不然會無法設定 ![](https://i.imgur.com/kDHEQMz.png) ![](https://i.imgur.com/YIFU7jk.png) ![](https://i.imgur.com/ru378IL.png) ## 二、觸發條件:設定連結的存放區,推送檔案後自動執行構建動作 ![](https://i.imgur.com/MZKPrb6.png) ## 上面有兩個選項連結存放區、建立觸發條件,如果是用 GCP 本身的 GCSR 因為存放 GCP 本身的服務,所以直接建立觸發條件選擇存放區即可,如果是用 GitHub 或是 Bitbucket 就需要設定存放區連結 ![](https://i.imgur.com/1esasKb.png) ## 1.連結存放區 ( GitHub ) ![](https://i.imgur.com/ourbVFf.png) ![](https://i.imgur.com/2TVoVDN.png) ## 授權完開始設定,首先設定使用的專案 ![](https://i.imgur.com/7w1xxJ6.png) ![](https://i.imgur.com/I501Ylg.png) ## 選擇 GitHub 使用的倉庫 ![](https://i.imgur.com/gKdiOnI.png) ## 觸發條件設定,可以用 Cloud Build 幫你設定好的,也可略過自己設定 ![](https://i.imgur.com/VpvOEk5.png) ## 設定完成畫面,有需要再修改設定都可以在這邊點擊再回去調整 ![](https://i.imgur.com/NH8nRrk.png) ## 完成畫面 ![](https://i.imgur.com/ZZUpRjL.png) ## 接下來回到 Cloud Build 可以看到 Cloud Build 幫你設定好的觸發條件 ![](https://i.imgur.com/jH0zX1b.png) ## 預設的觸發條件不一定是想要的,這時可以自己建立一個新的觸發條件,或是把原本的修改 ## 點選預設觸發條件最後面三個點,選擇編輯 ![](https://i.imgur.com/hbwbu7x.png) ## 2.建立觸發條件 ![](https://i.imgur.com/1esasKb.png) ## 首先是為觸發條件命名,這個觸發條件是在做什麼的可以備註在說明上 ![](https://i.imgur.com/TsNbPIw.png) ## 選擇觸發條件跟存放區還有分支版本,會依據條件不同存放區跟分支會有些不同選項 ## 推送至分支版本:推送到指定分支後觸發,預設分支版本只有 master 跟全部2種,其他分支要自己手動打上去 ![](https://i.imgur.com/LBRbuFj.png) ![](https://i.imgur.com/uubHBZo.png) ![](https://i.imgur.com/GV4Lqyw.png) ## 推送新標記:推送標記後才會觸發 ![](https://i.imgur.com/4DmAfDD.png) ## 提取要求:只要在 githup 執行 pull request 就會觸發 ![](https://i.imgur.com/eV7wmea.png) ## 觸發有三種方式 ![](https://i.imgur.com/CPpNWMe.png) ## 1.除了所有者和合作者,所有者或合作者註釋/gcbrun 才會觸發2.無倫如何所有者或合作者註釋/gcbrun才會觸發 (因為1.2觸發方式一樣所以列一起) ![](https://i.imgur.com/TZDep0h.png) ![](https://i.imgur.com/J1xHhtT.png) ![](https://i.imgur.com/oaj3p6P.png) ![](https://i.imgur.com/2vF3eRE.png) ![](https://i.imgur.com/X4rZEUt.png) ## 3.不需要註釋便會觸發 ![](https://i.imgur.com/QhuptKq.png) ![](https://i.imgur.com/L0dWmCG.png) ![](https://i.imgur.com/yk2bzlR.png) ## 反轉運算規則:版本分支是使用正則表達式敘述,反轉則是反轉你所列規則,如下圖觸發條件只有1個分支1個主線,選擇test分支反轉後會變成master主線 ![](https://i.imgur.com/gY0M56R.png) ## 納入和忽略的檔案篩選器 ## 納入的檔案篩選器:推送指定的檔案變更才會自動執行構建作業 ![](https://i.imgur.com/00qfOuK.png) ## 忽略的檔案篩選器:推送指定的檔案變更不會執行自動建構作業 ![](https://i.imgur.com/vym4rcd.png) ## 如果同時在納入和忽略檔案篩選器指定同一個檔案,無論檔案如何推送變更都不會有動作 ![](https://i.imgur.com/0LOGeu9.png) ## 建構作業設定:選擇構建用配置文件 ## git自動設定 ## cloudbuild.yaml:建構配置文件 ## [官方配置文件]( https://cloud.google.com/cloud-build/docs/build-config ) ## 文件配置: ## steps:構建配置文件中的steps部分包含您希望Cloud Build執行的構建步驟 ``` steps: ``` ## name:使用構建步驟的name字段來指定Cloud Builder,這是一種運行常見工具的容器映像。您可以在構建步驟中使用構建器來執行任務 ## [官方提供內建的指令]( https://github.com/GoogleCloudPlatform/cloud-builders ) ## EX: ``` steps: - name: 'gcr.io/cloud-builders/docker' ``` ## Cloud Builder:是裝有常用語言和工具的容器映像。您可以配置Cloud Build,以便在這些構建器的上下文中運行特定命令 ## [社區提供內建的指令]( https://github.com/GoogleCloudPlatform/cloud-builders-community ) ## EX: ``` steps: - name: node entrypoint: npm args: ['install'] ``` ## arges:添加步驟參數 ## EX: ``` steps: - name: 'gcr.io/cloud-builders/docker' args: ['build', '-t', 'gcr.io/my-project/my-image', '.'] ``` ## 變數:Cloud Build 提供預設替代變數,您也可以定義自己的替代變數 ## [官方變數文章]( https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values?hl=zh-cn ) ## EX: ``` steps: - name: 'gcr.io/cloud-builders/docker' args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/nginx:$COMMIT_SHA', '.' ] - name: 'gcr.io/cloud-builders/docker' args: ['push', 'gcr.io/$PROJECT_ID/nginx:$COMMIT_SHA'] ``` ## 替代變數: - 替代變數必須以下劃線*( )開頭,並且只能使用大寫字母和數字(遵循正則表達式格式[A-Z0-9]+)* - 參數數量的上限為100個。參數鍵的長度上限為100個字節,參數值的長度上限為4000個字節 - 如需使用替代變量,請使用 substitutions 參數 ## EX: ``` steps: - name: 'gcr.io/cloud-builders/docker' args: [ 'build', '-t', 'gcr.io/${_PROJECT_ID}/nginx:${_TEST}', '.' ] - name: 'gcr.io/cloud-builders/docker' args: ['push', 'gcr.io/${_PROJECT_ID}/nginx:${_TEST}'] substitutions: _TEST: v1.0 ``` ## Dockerfile:輸入 Dockerfile 路徑、名稱 ``` 映像檔名預設是 gcr.io/專案名稱/連結存放區名稱:變數 ``` ![](https://i.imgur.com/tluovS9.png) ## 如果 Dockerfile 放在根目錄路徑就不需要設定 ![](https://i.imgur.com/jGsXMdJ.png) ## 替代變數:與 cloudbuild.yaml 一樣 Cloud Build 提供預設替代變數,您也可以定義自己的替代變數 ![](https://i.imgur.com/BBn7nTX.png) ## 官方預設變數是給 cloudbuild.yaml 使用,GCP 上的設定使用的是自己定義的替代變數,定義完 cloudbuild 也要使用一樣的定義 ## EX: ``` steps: - name: 'gcr.io/cloud-builders/docker' args: [ 'build', '-t', 'gcr.io/${_PROJECT_ID}/nginx:$COMMIT_SHA', '.' ] - name: 'gcr.io/cloud-builders/docker' args: ['push', 'gcr.io/${_PROJECT_ID}/nginx:$COMMIT_SHA'] ``` ## 與 cloudbuild.yaml 同樣的替代變數寫法 ![](https://i.imgur.com/haUbSeT.png) ## 三、紀錄:觸發條件成功狀況基本資訊和過程 ![](https://i.imgur.com/hqPNbxo.png) ## 上方有個停止串流版本,點擊後推到 Container Registry 的 image 標記部分就不會再有版號 ![](https://i.imgur.com/D4UvLuh.png) ![](https://i.imgur.com/Ws95X0O.png) ## 篩選:選擇想要看的紀錄 ![](https://i.imgur.com/luR2Cjz.png) ![](https://i.imgur.com/YrpiYWy.png) ## 點擊版本,可以查看建構作業紀錄等資訊 ![](https://i.imgur.com/UVnD6WA.png) ![](https://i.imgur.com/S15dDwU.png) ## 點擊分頁可以看到詳細資料,來源:連接到 GCSR,修訂版本:可以看到更改了什麼 ![](https://i.imgur.com/3HlsS7X.png) ![](https://i.imgur.com/MIreuxz.png) ![](https://i.imgur.com/ZHL9iOc.png) ## 建構作業構建:可以把構建紀錄下載下來 ![](https://i.imgur.com/PEnBZ1m.png) ## 來源跟修訂版本也能在記錄首頁點擊連結查看 ![](https://i.imgur.com/gFwldA1.png) ![](https://i.imgur.com/ys1KJhO.png) ## 四、資訊主頁:觸發條件的一些基本資訊 ![](https://i.imgur.com/N0KlbBG.png) ## 點擊日期連結到構作業紀錄,來源:連接到 GCSR ![](https://i.imgur.com/Kf0XoIK.png) ![](https://i.imgur.com/wOLCbOB.png) ## 點擊查看全部,會把這個觸發條件構建過的紀錄篩選出來 ![](https://i.imgur.com/PIko8YU.png) ![](https://i.imgur.com/ps55Ssy.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully