简体   繁体   English

如何在 python 中使用 Jenkins CI 管道代码

[英]How to use Jenkins CI pipeline code in python

I am new to Jenkins, and I need to use python to read some user credentials which are stored on Jenkins, I am confused about how to do that.我是 Jenkins 的新手,我需要使用 python 来读取存储在 Jenkins 上的一些用户凭据,我对如何做到这一点感到困惑。

I have created some global credentials in my local jenkins.我在本地 jenkins 中创建了一些全局凭据。 I want to use python to read and use these credentials.我想使用 python 来读取和使用这些凭据。

在此处输入图像描述

The above photo is the credential I created.上面的照片是我创建的凭证。

I also have some jenkins CI pipeline code for reading and using the credentials, and I want to know is there some way allow me to use them in python?我还有一些用于读取和使用凭据的 jenkins CI 管道代码,我想知道有什么方法可以让我在 python 中使用它们吗?

在此处输入图像描述

When you use withCredentials block, you can use uname and pass as the environment variables.当您使用withCredentials块时,您可以使用unamepass作为环境变量。 I'm not good at Python, but os.environ['uname'] and os.environ['pass'] can be used inside the block.我不擅长 Python,但是os.environ['uname']os.environ['pass']可以在块内使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM