Skip to content

feat:python插件支持编译运行的时使用独立虚拟环境执行#12656#12727

Open
yjieliang wants to merge 28 commits into
TencentBlueKing:masterfrom
yjieliang:feat-12656
Open

feat:python插件支持编译运行的时使用独立虚拟环境执行#12656#12727
yjieliang wants to merge 28 commits into
TencentBlueKing:masterfrom
yjieliang:feat-12656

Conversation

@yjieliang

Copy link
Copy Markdown
Collaborator

No description provided.

@yjieliang yjieliang closed this Mar 24, 2026
@yjieliang yjieliang reopened this Mar 24, 2026
yjieliang added 17 commits May 11, 2026 13:38
# Conflicts:
#	src/backend/ci/core/worker/worker-api-sdk/src/main/kotlin/com/tencent/devops/worker/common/api/atom/AtomArchiveResourceApi.kt
#	src/backend/ci/core/worker/worker-common/src/main/kotlin/com/tencent/devops/worker/common/api/atom/AtomArchiveSDKApi.kt
@@ -72,3 +72,7 @@ const val LOG_FILE_LENGTH_LIMIT = 1073741824 // 1 GB = 1073741824 Byte
val PIPELINE_SCRIPT_ATOM_CODE = listOf("PipelineScriptDev", "PipelineScriptTest", "PipelineScript")

const val BK_CI_ATOM_EXECUTE_ENV_PATH = "BK_CI_ATOM_EXECUTE_ENV_PATH"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重构把各实现里的 System.setProperty(BK_CI_ATOM_EXECUTE_ENV_PATH, ...) 全部删掉了(改成 return)。但内部AtomRunEnvPrepareTask 插件仍在用旧的读取方式: val atomExecutePath = System.getProperty(BK_CI_ATOM_EXECUTE_ENV_PATH)

var convertTarget = if (!atomExecuteEnvPath.isNullOrBlank()) {
val fullPath = "$atomExecuteEnvPath${File.separator}$target"
// Windows路径含反斜杠,用双引号包裹防止被shell错误解析
if (osType == OSType.WINDOWS) "\"$fullPath\"" else fullPath

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target 通常是带参数的整条命令(如 python main.py),这里把"路径 + 空格 + 参数"整体拼成 fullPath 后再整体加引号,结果是 "C:...\Scripts\python main.py",Windows 会把它当成一个带空格的可执行文件名 → 执行失败。正确做法应只给可执行文件那一段加引号(就像同文件 handleAtomPreCmd 和 MarketAtomTask.replacePipWithAbsolutePath 里对 pip 的处理那样,引号只包路径、参数在引号外)。Linux 不受影响。触发条件是 Windows + 启用 venv + 命中白名单,影响面有限,但在该场景下是确定性失败。

private val businessConfigService: BusinessConfigService
) {
private val logger = LoggerFactory.getLogger(AtomWhitelistConfigService::class.java)
private val objectMapper = ObjectMapper()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复用 JsonUtil/共享 mapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants