gpt4 book ai didi

docker - Artifactory rtBuildInfo不在Jenkins Docker管道中收集环境变量

转载 作者:行者123 更新时间:2023-12-02 21:06:55 27 4
gpt4 key购买 nike

我想使用Artifactory插件在Jenkins声明性dockerized管道内收集env变量。

pipeline {
agent {
docker {
image 'node:10.16'
}
}
stages {
stage ('Build') {
// This publish build info but without env variables:
rtBuildInfo captureEnv: true
rtPublishBuildInfo serverId: "Artifactory1"
// This publish build info WITH env variables:
script {
server = Artifactory.server "Artifactory1"

buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
buildInfo.env.collect()
server.publishBuildInfo buildInfo
}
}
}
}

因此,使用脚本语法可以正常工作,而声明式则不能。我正在关注以下JFrog文档: https://www.jfrog.com/confluence/display/RTF/Declarative+Pipeline+Syntax#DeclarativePipelineSyntax-PublishingBuild-InfotoArtifactory

最佳答案

rtBuildInfo captureEnv: truebuildInfo.env.capture = true

set the Build-Info object to automatically capture environment variables while downloading and uploading files



这意味着env变量将仅在上载和下载期间收集。
buildInfo.env.collect(),但是

collect environment variables at any point in the script



这就是在您的情况下收集env变量的原因。声明式不支持类似选项。

关于docker - Artifactory rtBuildInfo不在Jenkins Docker管道中收集环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57431966/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com