简体   繁体   English

如何在 jenkins job xml 中为 github 设置用户名和密码?

[英]how to set username and password for github in jenkins job xml?

I am taking git repository,username and password as input from user and am creating a jenkins job using the below config.xml我将 git 存储库、用户名和密码作为用户的输入,并使用以下 config.xml 创建 jenkins 作业

<scm class="hudson.plugins.git.GitSCM" plugin="git@3.0.0">
    <configVersion>2</configVersion>
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
        **<url>"git repository path"</url>**
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>    
  </scm>

I don't know the syntax for sending username and password in xml.我不知道在 xml 中发送用户名和密码的语法。 Where should I add username and password in xml我应该在哪里在xml中添加用户名和密码

Jenkins uses encryption for the password it stores so you'll need to encrypt your password . Jenkins 对其存储的密码使用加密,因此您需要对密码进行加密 Because you didn't specify your Jenkins Master version or which Git SCM plugin version you're using, the safest way to see the format of the configuration is to do as suggested in your question's comments and create a dummy job that uses Git, and see how to create that section inthe job.因为您没有指定您的 Jenkins Master 版本或您使用的 Git SCM 插件版本,所以查看配置格式的最安全方法是按照您的问题评论中的建议进行操作并创建一个使用 Git 的虚拟作业,并且了解如何在作业中创建该部分。

Good luck!祝你好运!

I didn't know but there is an easy way to give username and password.我不知道,但有一种简单的方法可以提供用户名和密码。 I explicitly gave username and password separated by a colon before @ in the url.我在 url 中的@ 之前明确给出了用冒号分隔的用户名和密码。

https:// username:password @bitbucket.org/username/my_jenkins.git https://用户名:密码@bitbucket.org/username/my_jenkins.git

Please refer to below code:请参考以下代码:

<scm class="hudson.plugins.git.GitSCM" plugin="git@3.0.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
  <hudson.plugins.git.UserRemoteConfig>
    <url>https://username:password@bitbucket.org/username/my_jenkins.git</url>
  </hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>    

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

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