简体   繁体   English

如何获取Jenkins用户名和密码属性

[英]How to get Jenkins username and password property

I have a Jenkins job where I login to a website. 我有一个詹金斯(Jenkins)工作,我登录到一个网站。 The username and password for the website is the same username and password I use for Jenkins. 该网站的用户名和密码与我用于Jenkins的用户名和密码相同。 I want to get the Jenkins username and password and and pass it to the java code i have written to login to the website. 我想获取Jenkins用户名和密码,并将其传递给我编写的用于登录网站的Java代码。

How do I get the Jenkins Username and Password properties? 如何获得Jenkins用户名和密码属性?

Background: Lets say I use "username1" and "password1" to login to Jenkins. 背景:假设我使用“ username1”和“ password1”登录到Jenkins。 I have a website that uses this same login credentials. 我有一个使用相同登录凭据的网站。 I have a jenkins job created to login to this website. 我创建了一个詹金斯工作来登录该网站。 This jenkins job is used by a lot of people. 这个詹金斯工作被很多人使用。 I want to write the Java code in such a way that when each person login to the system and run this jenkin job, it will get the username and password that this person logged into jenkins and use that username and password to login to the website. 我想以这样的方式编写Java代码:当每个人登录系统并运行此jenkin作业时,它将获得此人登录jenkins的用户名和密码,并使用该用户名和密码登录网站。 So no one will be able to get the password of others. 因此,没有人能够获得他人的密码。 They will be using their own username and password. 他们将使用自己的用户名和密码。

There is no generic solution for this. 没有通用的解决方案。

  • How users authenticate towards Jenkins is configured in the "Global Security->Security Realm" section. 在“全局安全性->安全领域”部分中配置了用户对Jenkins进行身份验证的方式。
  • If you configure, for example, LDAP-based authentication, then Jenkins will not store the entered credentials at all (for good reason). 例如,如果您配置基于LDAP的身份验证,则Jenkins将根本不存储输入的凭据(有充分的理由)。
  • Therefore, you will not be able to re-use user credentials for authentication towards other services. 因此,您将无法重新使用用户凭据对其他服务进行身份验证。

Only in the very special case where you select "Jenkins' own user database" as Security Realm, you might be able to retrieve the password. 仅在非常特殊的情况下,您选择“ Jenkins自己的用户数据库”作为Security Realm,您才可以检索密码。 However, local Jenkins credentials will conflict with your very idea sharing credentials with other services... 但是,本地Jenkins凭证将与您与其他服务共享凭证的想法冲突。

Possibly, delegating Jenkins authentication to a servlet container can help -- if you manage to connect the servlet container's authentication machinery to the services that you need to use. 将Jenkins身份验证委派给Servlet容器可能会有所帮助-如果您设法将Servlet容器的身份验证机制连接到需要使用的服务。

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

相关问题 如何从詹金斯传递应用程序用户名和密码到Maven - How to pass application userName and password from jenkins to maven 如何在Jenkins中隐藏SSH用户名,密码和私钥 - How to hide SSH username,password and private key in Jenkins 如何在Java中的GET请求中传递用户名和密码 - How to Pass Username and Password in GET Request in Java 如何获取mysql数据库的用户名和密码 - How to get username and password of mysql database 如何在使用 groovy 的获取请求中传递您的用户名和密码? - How to pass your username and password in a get request with groovy? 如何将用户名和密码字段输入Blackberry文本框? - How do I get the username and password field into a Blackberry Text Box? 如何从 Android 的 SharedPreferences 获取用户名和密码? - How can I get username and password from SharedPreferences in Android? 如何在不使用用户名或密码的情况下获取AdminClient Websphere对象? - How to get an AdminClient Websphere object without using a username or password ? 给定协议,用户名,密码,主机名,端口和路径如何获取URL - Given protocol, username, password, hostname, port and path how to get a URL 如何在不通过用户名和密码的情况下获取Salesforce Sessionid? - How to get salesforce Sessionid without passing username& password?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM