gpt4 book ai didi

jenkins - Git 使用用户名和密码 checkout jenkins 管道中的外部项目

转载 作者:行者123 更新时间:2023-12-05 05:57:38 27 4
gpt4 key购买 nike

阅读 this answer从jenkins pipeline check out 外部项目的方式如下:

git branch: 'master',
credentialsId: '12345-1234-4696-af25-123455',
url: 'ssh://git@bitbucket.org:company/repo.git'

帖子的作者还说:

If you're using the ssh url then your credentials must be username + private key. If you're using the https clone url instead of the ssh one, then your credentials should be username + password.

但是,不完全清楚第二种情况是如何工作的(https URL 和用户名 + 密码)...在这种情况下,cradentialsId 使用哪种语法?或者该字段未使用而其他字段用于指定用户名和密码?有人可以提供一个例子吗?

谢谢!

最佳答案

通过以下方式将用户名和密码存储在 Jenkins 上:

https://www.jenkins.io/doc/book/using/using-credentials/

Adding new global credentials To add new global credentials to yourJenkins instance:

If required, ensure you are logged in to Jenkins (as a user with theCredentials > Create permission). From the Jenkins home page (i.e. theDashboard of the Jenkins classic UI), click Manage Jenkins > ManageCredentials. image

Under Stores scoped to Jenkins on the right, click on Jenkins. image

Under System, click the Global credentials (unrestricted) link toaccess this default domain. image

Click Add Credentials on the left. Note: If there are no credentialsin this default domain, you could also click the add some credentialslink (which is the same as clicking the Add Credentials link). Fromthe Kind field, choose the type of credentials to add. From the Scopefield, choose either: Global - if the credential/s to be added is/arefor a Pipeline project/item. Choosing this option applies the scope ofthe credential/s to the Pipeline project/item "object" and all itsdescendent objects. System - if the credential/s to be added is/arefor the Jenkins instance itself to interact with system administrationfunctions, such as email authentication, agent connection, etc.Choosing this option applies the scope of the credential/s to a singleobject only. Add the credentials themselves into the appropriatefields for your chosen credential type: Secret text - copy the secrettext and paste it into the Secret field. Username and password -specify the credential’s Username and Password in their respectivefields. Secret file - click the Choose file button next to the Filefield to select the secret file to upload to Jenkins. SSH Usernamewith private key - specify the credentials Username, Private Key andoptional Passphrase into their respective fields. Note: Choosing Enterdirectly allows you to copy the private key’s text and paste it intothe resulting Key text box. Certificate - specify the Certificate andoptional Password. Choosing Upload PKCS#12 certificate allows you toupload the certificate as a file via the resulting Upload certificatebutton. Docker Host Certificate Authentication - copy and paste theappropriate details into the Client Key, Client Certificate and ServerCA Certificate fields. In the ID field, specify a meaningfulcredential ID value - for example,jenkins-user-for-xyz-artifact-repository. The inbuilt (default)credentials provider can use upper- or lower-case letters for thecredential ID, as well as any valid separator character, othercredential providers may apply further restrictions on allowedcharacters or lengths. However, for the benefit of all users on yourJenkins instance, it is best to use a single and consistent conventionfor specifying credential IDs. Note: This field is optional. If you donot specify its value, Jenkins assigns a globally unique ID (GUID)value for the credential ID. Bear in mind that once a credential ID isset, it can no longer be changed. Specify an optional Description forthe credential/s. Click OK to save the credentials

然后,使用上述代码中 credentialsId 字段中的 ID。

关于jenkins - Git 使用用户名和密码 checkout jenkins 管道中的外部项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68769923/

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