[JIRA] (JENKINS-58209) how to use perforce credential in pipeline

26 views
Skip to first unread message

luckyhk.lee@samsung.com (JIRA)

unread,
Jun 26, 2019, 8:11:02 AM6/26/19
to jenkinsc...@googlegroups.com
Hokwang Lee created an issue
 
Jenkins / New Feature JENKINS-58209
how to use perforce credential in pipeline
Issue Type: New Feature New Feature
Assignee: Unassigned
Components: p4-plugin
Created: 2019-06-26 12:10
Priority: Minor Minor
Reporter: Hokwang Lee

Hi,

 

Is it possible to use perforce password credential in pipeline?

 

like,

withCredentials([ usernamePassword(
  credentialsId: 'perforce',
  usernameVariable: 'P4_USER',
  passwordVariable: 'P4_PASSWORD')
]) {
  ...
}

If not provided, please add this feature.

 

Thanks,

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

kwirth@perforce.com (JIRA)

unread,
Jun 26, 2019, 9:51:03 AM6/26/19
to jenkinsc...@googlegroups.com
Karl Wirth assigned an issue to Karl Wirth
Change By: Karl Wirth
Assignee: Karl Wirth

kwirth@perforce.com (JIRA)

unread,
Jun 26, 2019, 9:51:03 AM6/26/19
to jenkinsc...@googlegroups.com
Karl Wirth commented on New Feature JENKINS-58209
 
Re: how to use perforce credential in pipeline

Hi Hokwang Lee. No I dont think that is possible. What is the usage case? For example do you have may Jenkins Masters and this would cut down on local configuration?

kwirth@perforce.com (JIRA)

unread,
Jun 26, 2019, 9:51:04 AM6/26/19
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
 
Change By: Karl Wirth
Labels: P4_SUPPORT

kwirth@perforce.com (JIRA)

unread,
Jul 1, 2019, 6:40:02 AM7/1/19
to jenkinsc...@googlegroups.com
 
Re: how to use perforce credential in pipeline

Hello Hokwang Lee - Did you see my last message? Can you please provide an example of how you would use this.

In my testing the 'withCredentials' seems to be used to access the Perforce password already stored in the credential 'perforce' (from your example). For me this works and I can access the password in the variable 'P4_PASSWORD' from within my Jenkinsfile.

luckyhk.lee@samsung.com (JIRA)

unread,
Jul 1, 2019, 7:36:02 PM7/1/19
to jenkinsc...@googlegroups.com

Hi, Karl Wirth

I've tested.

 

1) When I create "Username with password" kind in Jenkins Credentials page,

I can use this in below format. There's no problem.

withCredentials([ usernamePassword(

2) I just ask that can I use "Perforce Password Credential" kind or not.

Like

withCredentials([ perforcePassword(

Now I should create both "Username with password" and "Perforce Password Credential".

kwirth@perforce.com (JIRA)

unread,
Jul 2, 2019, 12:08:03 PM7/2/19
to jenkinsc...@googlegroups.com

Hello Hokwang Lee - I will correct my original response and say yes it is possoble. As you have found  'usernamePassword' gets the correct information:

node {
 withCredentials([usernamePassword(credentialsId: 'MyJenkinsP4Credential', usernameVariable: 'USERNAME', passwordVariable: 'PASS')]) {
    sh '''
      set +x
      echo "User is $USERNAME " > out.txt
      echo "Pass is $PASS" >> out.txt
    '''
  }
}

Important note: If you try to echo the variables or 'out.txt' to job console in Jenkins you will see the user and password replaced with the text '****' . However the contents on disk does contain my credentials:

$ cat /var/lib/jenkins/workspace/JENKINS-58209-withCredetials/out.txt
User is jenkinsuser 
Pass is Password123

Is there any reason why you need a 'perforcePassword' and how would it differ from usernamePassword?

 

 

 

 

 

luckyhk.lee@samsung.com (JIRA)

unread,
Jul 11, 2019, 2:45:05 AM7/11/19
to jenkinsc...@googlegroups.com

Karl,

 

Thanks, I checked, there's no problem.

You can close this issue.

kwirth@perforce.com (JIRA)

unread,
Jul 11, 2019, 9:48:02 AM7/11/19
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Jul 11, 2019, 9:49:02 AM7/11/19
to jenkinsc...@googlegroups.com
Karl Wirth closed an issue as Fixed
 

Yes the Perforce credentials are accessible using 'withCredentials'.

Change By: Karl Wirth
Status: Open Closed
Resolution: Fixed
Reply all
Reply to author
Forward
0 new messages