susanoo
susanoo

Reputation: 85

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

<scm class="hudson.plugins.git.GitSCM" plugin="[email protected]">
    <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. Where should I add username and password in xml

Upvotes: 2

Views: 1330

Answers (2)

mazend
mazend

Reputation: 464

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.

https://username:password@bitbucket.org/username/my_jenkins.git

Please refer to below code:

<scm class="hudson.plugins.git.GitSCM" plugin="[email protected]">
<configVersion>2</configVersion>
<userRemoteConfigs>
  <hudson.plugins.git.UserRemoteConfig>
    <url>https://username:[email protected]/username/my_jenkins.git</url>
  </hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>    

Upvotes: 0

Dvir669
Dvir669

Reputation: 8670

Jenkins uses encryption for the password it stores so you'll need to encrypt your password. 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.

Good luck!

Upvotes: 1

Related Questions