Jenkins:如何使用 GitHub webhook 在 JenkinsFile 中安全地声明环境变量?

发布于 2025-01-12 05:28:28 字数 499 浏览 2 评论 0原文

我是 Jenkins 的初学者,我必须为项目构建 Jenkins 管道。我决定使用 GitHub 作为 SCM。 GitHub 在每次推送时借助 webhook 启动 Jenkins 管道。

Jenkins 管道是一个多分支管道。这样我就可以在每个 GitHub 分支上拥有一个 Jenkinsfile。

借助我的 Jenkins 管道,我还使用 Terraform 在 AWS 上构建 EC2 实例。因此,我必须管理我的 IAM 凭证以及我可以在工作流程中使用的其他一些重要变量。

如何在工作流程中保护我的变量?我的 jenkinsfile 版本在 Github 上。如果我在 JenkinsFile 中使用“env”步骤,我的所有变量都将可见。如果我不使用 GitHub Action,GitHub 不允许管理环境变量。我现在不知道 Jenkins 插件是否可以帮助我或 Jenkins 上我不知道的功能?我知道 Jenkins 上的全局环境变量,但我的所有变量都集中在一个项目上,而不是所有项目上。

感谢您的帮助。 加蒂

I'm beginner with Jenkins and I must build a Jenkins Pipeline for a project. I decided to use GitHub as SCM. GitHub launch Jenkins pipeline thanks to webhook on each push.

The Jenkins pipeline is a multibranche pipeline. So I can have one Jenkinsfile on each GitHub branch.

I also use Terraform to build EC2 Instance on AWS thanks to my Jenkins pipeline. So I must manage my IAM credentials and some other important variables that I can be able to use during the workflow.

How can I secure my variables during the workflow ? My jenkinsfile is versioned on Github. If I use the "env" step in JenkinsFile, all my variables will be visible. GitHub doesn't allow to manage environment variable if I didn't use GitHub Action. I don't now if a Jenkins plugin can help me or a function that I not know on Jenkins ? I know the global environment variables on Jenkins but all my variables are focused on one project and not on all.

Thank you for your help.
Gati

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文