顯示具有 Nexus 標籤的文章。 顯示所有文章
顯示具有 Nexus 標籤的文章。 顯示所有文章

2024/07/15

Ubuntu 22.04.4 LTS Upgrading Nexus Repository from 3.66.0-02 to 3.70.1

#切換至目錄
cd /opt

# 停止服務
sudo systemctl stop nexus

# 移除舊版本
sudo rm -fr nexus

# 先將資料備份
sudo mv sonatype-work sonatype-work-temp

# 下載新版本
sudo wget https://download.sonatype.com/nexus/3/nexus-3.70.1-02-java8-unix.tar.gz

# 解壓縮
sudo tar -xvf nexus-3.70.1-02-java8-unix.tar.gz

# 重新改名
sudo mv nexus-3.70.1-02 nexus

#將備份遷移至新的
sudo rm -fr sonatype-work/*
sudo mv sonatype-work-temp/* sonatype-work/

# 給予Nexus權限
sudo chown -R nexus:nexus nexus
sudo chown -R nexus:nexus sonatype-work

# 添加運行使用者
sudo sed -i 's/^;run_as_user=""/run_as_user="nexus"/' /opt/nexus/bin/nexus.rc

# 啟動服務
sudo systemctl start nexus

2023/11/09

整合 GitLab Private Repository with Jenkins and Nexus Repository

如果還不知道如何使用Webhook可以先至『GitLab 透過 Webhook 連動 Jenkins』查看
目標:代碼提交時,透過Jenkins自動處理上傳的代碼並發布到Maven Repository
 記得要先在Maven Project的pom.xml加入<distributionManagement>和maven-compiler-plugin,下方是示範的pom.xml


2023/09/04

Nexus Repository 無法更改密碼問題

再Role多加上「nx-userschangepw」儲存即可



Visual Studio 2022 解決NuGet 使用私倉 重啟需要重新輸入帳號密碼問題 Nexus Repository

最近身體堪憂,早上剛找完醫生報到,到家時看到公司的前輩問我為什麼VS每次重新開啟後都需要輸入帳號密碼

接著我就開始進入滿臉問號的情況

一開始排查方向往Nginx Proxy方面去找,但發現配置上沒有任何問題

接著開始著手Nexus Repository Role的問題,也沒發現有缺少的配置

最後開始著手研究了下NuGet所儲存的配置檔

在資料夾輸入下方指令找到NuGet配置檔
%userprofile%\AppData\Roaming\NuGet



找到了「為 NuGet 設定需驗證的 proxy」,比較後確定配置檔案有差異,後來又找到了這篇「Nuget私包源记住用户名和密码

2023/09/02

使用Nexus Repository 3.59.0-01 作為 NPM Registry 倉庫 上傳及安裝

首先寫好package.json的檔案:
{
  "name": "test",
  "version": "0.0.1",
  "description": "Test npm",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "homepage": "https://xxxxx",
  "keywords": [],
  "author": {
    "name": "Peter Fang",
    "email": "xxxxxx@gmail.com"
  },
  "repository": {
    "type": "git",
    "url": "git+https://xxxxx@bitbucket.org/xxxxxx/xxxxx.git"
  },
  "license": "BSD"
}


接著在要上傳的package輸入

Nexus Repository 3.59.0-01 Role

最近新來的前輩請我去架設了Nexus Repository,正巧來學習下
Role分為兩個權限「Nexus role」和「External Role Mapping」
Nexus role:內部使用
External Role Mapping:外部使用
這套本身支援聚合,所以可以集合的方式設定多種權限
基礎的權限我就設定如下:
nx-component-upload
nx-repository-admin-*-*-add
nx-repository-admin-*-*-browse
nx-repository-admin-*-*-edit
nx-repository-admin-*-*-edit
nx-repository-view-*-*-*
nx-repository-view-*-*-add
nx-repository-view-*-*-browse
nx-repository-view-*-*-edit
nx-repository-view-*-*-read
nx-repository-view-r-*-browse
nx-repository-view-raw-*-browse
nx-search-read

之後將這組權限包含在其他Role,即可明確區分開發的團隊權限
參考資料:
https://help.sonatype.com/repomanager3/nexus-repository-administration/access-control/roles

Nexus Repository 3.59.0-01 npm Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

 找到security/realms將npm Bearer Token Realm加入到Active儲存即可



2023/08/18

Ubuntu 22.04 LTS Install Nexus Repository Manager

sudo apt-get update
sudo apt upgrade -y
sudo apt install openjdk-8-jre-headless vim -y
cd /opt
sudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
sudo tar -zxvf latest-unix.tar.gz
sudo mv nexus-3.59.0-01 nexus
sudo adduser nexus
sudo chown -R nexus:nexus /opt/nexus
sudo mkdir /opt/sonatype-work
sudo chown -R nexus:nexus /opt/sonatype-work
# 添加運行使用者
sudo vim /opt/nexus/bin/nexus.rc
run_as_user="nexus"

# 編輯Nexus Service
sudo vim /etc/systemd/system/nexus.service
[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target

# 啟動Nexus服務
sudo systemctl enable --now nexus

Nginx配置:
upstream backend {
    server 10.10.10.52:8081;
}

server {
    listen 80;
    listen [::]:80;
    http2 on;
    server_name xx.com;
    rewrite ^(.*) https://xx.com$1 permanent;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name xx.com;
    ssl_certificate fullchain.pem;
    ssl_certificate_key privkey.pem;
    access_log /var/log/nginx/nexus.access.log;
    error_log /var/log/nginx/nexus.error.log;

    location / {
        proxy_pass  http://backend;
        proxy_max_temp_file_size 0;
        client_max_body_size 1G;
        client_body_buffer_size 128k;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto "https";
    }
}