使用 Nx 在 Jenkins 中進行 CI/CD 的最佳方式 (Best way for CI/CD in Jenkins with Nx)


問題描述

使用 Nx 在 Jenkins 中進行 CI/CD 的最佳方式 (Best way for CI/CD in Jenkins with Nx)

我對 Nx Workspace 中的最佳實踐有一些疑問和一個大問題。

我想將我的所有項目移到 Nx 工作區,因為我有很多共享庫。

這將導致多個應用程序只有一個 bitbucket 存儲庫和一個 jenkins 管道。(我的 jenkins 管道正在 AWS 服務器上檢查、檢查、構建和部署我的應用程序。)

首先:什麼是這項工作的最佳選擇?正如許多文章和 Nrwl 文檔所說:我可以使用命令 nx affected 僅構建、部署受我的更改影響的應用程序。

但是這會導致這個錯誤jenkins 控制台

fatal: Not a valid object name master
fatal: No such ref: 'master'
nx affected

我嘗試過

npx nx affected ‑‑target=test ‑‑base=master
npx nx affected ‑‑target=test ‑‑base=origin/master
npx nx affected ‑‑target=test ‑‑base=remote/origin/master

但它們都沒有工作。


參考解法

方法 1:

You may want to reference ‑‑base=HEAD~1 as this documentation suggests: https://nx.dev/l/r/ci/monorepo‑ci‑jenkins

This happened to work for our CICD dev and hope it help you!

方法 2:

I had same issue. Fetching needed for comparison branch before running commands helped:

git fetch origin master:refs/remotes/origin/master
npx nx affected ‑‑target=test ‑‑base=origin/master

(by achtlosjonniesomeone_new)

參考文件

  1. Best way for CI/CD in Jenkins with Nx (CC BY‑SA 2.5/3.0/4.0)

#nrwl #jenkins #nrwl-nx






相關問題

Ng add @nrwl/workspace throws Cannot read property 'paths' of undefined (Ng add @nrwl/workspace throws Cannot read property 'paths' of undefined)

如何為非js框架創建原理圖? (How to create a schematic for non js framework?)

禁止在 Nrwl Nx 的同一庫中導入桶文件 (Disallow barrel file imports within the same library in Nrwl Nx)

如何強制 nrwl nx 尊重標籤更新? (How can I force nrwl nx to respect tag updates?)

將 Nx 工作區部署到 Google App Engine (Deploying Nx workspace to Google App Engine)

如何讓 Jest 正確轉換 node_modules/@nativescript/core?Jest + NativeScript + Angular + Nx (How can I get Jest to transpile node_modules/@nativescript/core properly? Jest + NativeScript + Angular + Nx)

使用 Nx 在 Jenkins 中進行 CI/CD 的最佳方式 (Best way for CI/CD in Jenkins with Nx)

如何使用短路徑在 Nx Workspace 中導入? (How to use short paths for importing in Nx Workspace?)

將 nx 與 angular.json 一起使用時使用哪個構建器 (Which builder to use when using nx with angular.json)







留言討論