ci: harden Jenkins credential handling

这个提交包含在:
XuqmGroup 2026-07-27 12:33:53 +08:00
父节点 144fd80f65
当前提交 9a1d351468
共有 2 个文件被更改,包括 29 次插入10 次删除

16
Jenkinsfile vendored
查看文件

@ -4,8 +4,7 @@ pipeline {
environment { environment {
NEXUS_REGISTRY = 'https://nexus.xuqinmin.com/repository/npm-hosted/' NEXUS_REGISTRY = 'https://nexus.xuqinmin.com/repository/npm-hosted/'
NEXUS_READ_REGISTRY = 'https://nexus.xuqinmin.com/repository/npm/' NEXUS_READ_REGISTRY = 'https://nexus.xuqinmin.com/repository/npm/'
GIT_URL = 'https://xuqinmin.com/xuqmGroup/XuqmGroup-RNSDK.git' ANDROID_SDK_GIT_URL = 'ssh://git@xuqinmin.com:2222/xuqmGroup/XuqmGroup-AndroidSDK.git'
ANDROID_SDK_GIT_URL = 'https://xuqinmin.com/xuqmGroup/XuqmGroup-AndroidSDK.git'
} }
options { options {
@ -254,18 +253,19 @@ pipeline {
continue continue
} }
echo "Publishing ${mod} from ${dir} (tag: ${env.NPM_TAG})" echo "Publishing ${mod} from ${dir} (tag: ${env.NPM_TAG})"
bat """ try {
copy .npmrc ${dir}\\.npmrc bat "powershell -NonInteractive -Command \"Copy-Item -LiteralPath '.npmrc' -Destination '${dir}\\\\.npmrc' -Force\""
pnpm --dir ${dir} publish --tag ${env.NPM_TAG} --registry %NEXUS_REGISTRY% --no-git-checks bat "pnpm --dir ${dir} publish --tag ${env.NPM_TAG} --registry %NEXUS_REGISTRY% --no-git-checks"
del ${dir}\\.npmrc 2>nul || exit 0 } finally {
""" bat "powershell -NonInteractive -Command \"Remove-Item -LiteralPath '${dir}\\\\.npmrc' -Force -ErrorAction SilentlyContinue\""
}
} }
} }
} }
} }
post { post {
always { always {
bat 'del .npmrc 2>nul || exit 0' bat "powershell -NonInteractive -Command \"Remove-Item -LiteralPath '.npmrc' -Force -ErrorAction SilentlyContinue\""
} }
} }
} }

查看文件

@ -463,5 +463,24 @@ pnpm --dir packages/update test
- 同一脚本为每个 Android variant 生成自动初始化、buildId 与 BugCollect 构建开关 - 同一脚本为每个 Android variant 生成自动初始化、buildId 与 BugCollect 构建开关
元数据。RN 宿主无需额外应用 Android `com.xuqm.common` 插件;Debug 自动上报 元数据。RN 宿主无需额外应用 Android `com.xuqm.common` 插件;Debug 自动上报
保持关闭,Release 根据统一构建参数决定。 保持关闭,Release 根据统一构建参数决定。
- `@xuqm/rn-update@0.5.0-alpha.15` 已由 Jenkins 发布。App4 的 Debug 构建已证明 - `@xuqm/rn-update@0.5.0-alpha.16` 已由 Jenkins `sdk-rn-publish #67` 发布。
签名配置进入 APK;本次元数据修复仍需发布下一 alpha 后完成模拟器日志复核。 App4 使用 Nexus 精确版本完成 481 tasks Debug 构建、安装与冷启动,日志确认原生
签名配置和平台开关均已加载,不再出现 common 插件缺失或配置未找到。
### 2026-07-27 / Jenkins npm 凭据文件生命周期修复
- Jenkins Windows 发布阶段原先使用 `copy .npmrc package\\.npmrc`,真实日志中该
命令的路径解析不稳定;同时同一批处理块在 publish 失败时不会执行子包凭据文件
删除。该问题不改变 npm 包内容,但会让失败工作区残留临时认证文件。
- 发布循环改为 PowerShell `Copy-Item`,每个包的 `pnpm publish` 使用
`try/finally` 独立清理子包 `.npmrc`;阶段 `post.always` 继续清理根 `.npmrc`
凭据仍只从 Jenkins `NEXUS_CREDS` 注入,不写入仓库、构建归档或 npm 制品。
- 本修改尚未触发 Jenkins 验证;发布前必须先完成 Jenkinsfile 语法校验和一次真实
alpha 发布,确认成功与失败路径均不会保留 `.npmrc`
- Jenkins `sdk-rn-publish` 及其余 9 个 SDK 发布作业已从含认证信息的 HTTPS SCM URL
迁移为 `ssh://git@xuqinmin.com:2222/...`,统一绑定现有
`jenkins-ssh-key`;作业配置二次读取确认 URL 无内嵌凭据且 credentialsId 生效。
RN 的 Android 原生编译辅助检出同步改为 SSH URL,继续复用主 SCM 的凭据 ID。
- 工作区内 18 个 XuqmGroup 子仓库的本地 `origin` 也已改为 SSH,审计结果不再存在
`https://user:token@host` 形式。旧访问令牌曾出现在命令审计输出,必须在 Gitea
轮换;本文不记录其值。