<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Using GitLab CI/CD with a Bitbucket Cloud repository > 原文:[https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/bitbucket_integration.html](https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/bitbucket_integration.html) # Using GitLab CI/CD with a Bitbucket Cloud repository[](#using-gitlab-cicd-with-a-bitbucket-cloud-repository-premium "Permalink") GitLab CI / CD 可以通過以下方式與 Bitbucket Cloud 一起使用: 1. 創建一個[CI / CD 項目](../../user/project/ci_cd_for_external_repo.html) . 2. 通過 URL 連接您的 Git 存儲庫. 要將 GitLab CI / CD 與 Bitbucket Cloud 存儲庫一起使用: 1. 在 GitLab 中**為外部** **倉庫**創建一個**CI / CD** ,選擇" **按 URL 進行倉庫"**并創建項目. [![Create project](https://img.kancloud.cn/ae/29/ae29b6081132f2723cf31bb7d5e1c76c_1896x608.png)](img/external_repository.png) GitLab 將導入存儲庫并啟用[Pull Mirroring](../../user/project/repository/repository_mirroring.html#pulling-from-a-remote-repository-starter) . 2. 在 GitLab 中,創建具有`api`作用域的[個人訪問令牌](../../user/profile/personal_access_tokens.html) . 這將用于驗證來自 Web 鉤子的請求,該請求將在 Bitbucket 中創建,以將新提交通知 GitLab. 3. 在 Bitbucket 中,從**"設置">" Webhooks"**中創建一個新的 Web 掛鉤,以將新的提交通知 GitLab. 應該使用我們剛剛生成的用于身份驗證的個人訪問令牌,將 Web 掛鉤 URL 設置為 GitLab API 來觸發拉鏡像. ``` https://gitlab.com/api/v4/projects/<PROJECT_ID>/mirror/pull?private_token=<PERSONAL_ACCESS_TOKEN> ``` 網絡掛鉤觸發器應設置為" Repository Push". [![Bitbucket Cloud webhook](https://img.kancloud.cn/96/f4/96f474e023c793f57f278f858d280cba_1048x734.png)](img/bitbucket_webhook.png) 保存后,通過將更改推送到您的 Bitbucket 存儲庫來測試 Web 掛鉤. 4. 在 Bitbucket 中,從" **Bitbucket 設置">"應用程序密碼"中**創建一個**應用** **程序密碼,**以驗證構建狀態腳本設置來提交 Bitbucket 中的構建狀態. 存儲庫寫權限是必需的. [![Bitbucket Cloud webhook](https://img.kancloud.cn/f9/bb/f9bbbfde4c6c1769da929ae42bc30ad2_1162x1104.png)](img/bitbucket_app_password.png) 5. 在 GitLab 中,從**設置> CI / CD>環境變量中** ,添加變量以允許通過 Bitbucket API 與 Bitbucket 通信: `BITBUCKET_ACCESS_TOKEN` :上面創建的 Bitbucket 應用密碼. `BITBUCKET_USERNAME` :Bitbucket 帳戶的用戶名. `BITBUCKET_NAMESPACE` :如果您的 GitLab 和 Bitbucket 命名空間不同,請設置此項. `BITBUCKET_REPOSITORY` :如果您的 GitLab 和 Bitbucket 項目名稱不同,請設置此項. 6. 在 Bitbucket 中,添加腳本以將管道狀態推送到 Bitbucket. > 注意:在 GitLab 中所做的更改將被 Bitbucket 在上游進行的任何更改所覆蓋. 創建一個文件`build_status`并在下面插入腳本,然后在終端中運行`chmod +x build_status`以使腳本可執行. ``` #!/usr/bin/env bash # Push GitLab CI/CD build status to Bitbucket Cloud if [ -z "$BITBUCKET_ACCESS_TOKEN" ]; then echo "ERROR: BITBUCKET_ACCESS_TOKEN is not set" exit 1 fi if [ -z "$BITBUCKET_USERNAME" ]; then echo "ERROR: BITBUCKET_USERNAME is not set" exit 1 fi if [ -z "$BITBUCKET_NAMESPACE" ]; then echo "Setting BITBUCKET_NAMESPACE to $CI_PROJECT_NAMESPACE" BITBUCKET_NAMESPACE=$CI_PROJECT_NAMESPACE fi if [ -z "$BITBUCKET_REPOSITORY" ]; then echo "Setting BITBUCKET_REPOSITORY to $CI_PROJECT_NAME" BITBUCKET_REPOSITORY=$CI_PROJECT_NAME fi BITBUCKET_API_ROOT="https://api.bitbucket.org/2.0" BITBUCKET_STATUS_API="$BITBUCKET_API_ROOT/repositories/$BITBUCKET_NAMESPACE/$BITBUCKET_REPOSITORY/commit/$CI_COMMIT_SHA/statuses/build" BITBUCKET_KEY="ci/gitlab-ci/$CI_JOB_NAME" case "$BUILD_STATUS" in running) BITBUCKET_STATE="INPROGRESS" BITBUCKET_DESCRIPTION="The build is running!" ;; passed) BITBUCKET_STATE="SUCCESSFUL" BITBUCKET_DESCRIPTION="The build passed!" ;; failed) BITBUCKET_STATE="FAILED" BITBUCKET_DESCRIPTION="The build failed." ;; esac echo "Pushing status to $BITBUCKET_STATUS_API..." curl --request POST $BITBUCKET_STATUS_API \ --user $BITBUCKET_USERNAME:$BITBUCKET_ACCESS_TOKEN \ --header "Content-Type:application/json" \ --silent \ --data "{ \"state\": \"$BITBUCKET_STATE\", \"key\": \"$BITBUCKET_KEY\", \"description\": \"$BITBUCKET_DESCRIPTION\",\"url\": \"$CI_PROJECT_URL/-/jobs/$CI_JOB_ID\" }" ``` 7. 仍在 Bitbucket 中,創建一個`.gitlab-ci.yml`文件以使用該腳本將管道成功與失敗推送到 Bitbucket. ``` stages: - test - ci_status unit-tests: script: - echo "Success. Add your tests!" success: stage: ci_status before_script: - "" after_script: - "" script: - BUILD_STATUS=passed BUILD_KEY=push ./build_status when: on_success failure: stage: ci_status before_script: - "" after_script: - "" script: - BUILD_STATUS=failed BUILD_KEY=push ./build_status when: on_failure ``` 現在已將 GitLab 配置為從 Bitbucket 鏡像更改,運行在`.gitlab-ci.yml`配置的 CI / CD 管道,并將狀態推送到 Bitbucket.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看