[JIRA] (JENKINS-58250) how to use p4groovy in declarative pipeline

2 views
Skip to first unread message

luckyhk.lee@samsung.com (JIRA)

unread,
Jun 28, 2019, 4:27:02 AM6/28/19
to jenkinsc...@googlegroups.com
Hokwang Lee created an issue
 
Jenkins / Task JENKINS-58250
how to use p4groovy in declarative pipeline
Issue Type: Task Task
Assignee: Unassigned
Components: p4-plugin
Created: 2019-06-28 08:26
Priority: Minor Minor
Reporter: Hokwang Lee

Hi,

How can I use p4 groovy in declarative pipeline?

Karl Wirth, you told me that I can use below syntax, but I can't use this.

 

pipeline {
  agent {
    kubernetes {
     label 'test'
     yamlFile 'test.yaml'
    }
  }
  options {
    skipDefaultCheckout()
  }
  stages {
    stage('Run Test') {
      steps {
        container(name: 'test', shell: '/bin/bash') {
          p4 credential: 'p4_10.251.245.74_1667_perforce', workspace: templateSpec(charset: 'utf8', format: 'jenkins-${JOB_NAME}-${BUILD_ID}-${NODE_NAME}', pinHost: false, templateName: 'TEMPLATE')
          // and how to use p4.run('client', '-o') for example
        }
      }
    }
  }
}
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

kwirth@perforce.com (JIRA)

unread,
Jun 28, 2019, 6:09:02 AM6/28/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 28, 2019, 7:34:03 AM6/28/19
to jenkinsc...@googlegroups.com
Karl Wirth resolved as Fixed
Change By: Karl Wirth
Status: Open Resolved
Resolution: Fixed

kwirth@perforce.com (JIRA)

unread,
Jun 28, 2019, 7:34:03 AM6/28/19
to jenkinsc...@googlegroups.com
Karl Wirth commented on Task JENKINS-58250
 
Re: how to use p4groovy in declarative pipeline

Hi Hokwang Lee. P4Groovy is scripted pipeline code so please try a 'script' block as described in:

https://jenkins.io/doc/book/pipeline/syntax/

For example:

pipeline {
  agent { label 'master' }
  stages {
    stage("Repro") {
      steps {
             script {           
                def ws = [$class: 'StreamWorkspaceImpl',charset: 'none', format: 'test', pinHost: false,streamName: '//streams/main']     
                def p4 = p4(credential: 'JenkinsMaster', workspace: ws)
                def output = p4.run('info')
                output[0].each{key, value -> println ("${key} = ${value}");}
                }
            }
        }
    } 
}

kwirth@perforce.com (JIRA)

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

Hi Hokwang Lee - Did the above snippet help to solve the problem?

kwirth@perforce.com (JIRA)

unread,
Jul 1, 2019, 11:35:01 AM7/1/19
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
 
Change By: Karl Wirth
Labels: P4_SUPPORT

luckyhk.lee@samsung.com (JIRA)

unread,
Jul 1, 2019, 7:56:02 PM7/1/19
to jenkinsc...@googlegroups.com
Hokwang Lee commented on Task JENKINS-58250
 
Re: how to use p4groovy in declarative pipeline

Hi, Karl Wirth

 

Thanks for your help. 

 

You can close this issue.

kwirth@perforce.com (JIRA)

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

kwirth@perforce.com (JIRA)

unread,
Jul 11, 2019, 12:59:02 PM7/11/19
to jenkinsc...@googlegroups.com
Karl Wirth closed an issue as Fixed
 
Change By: Karl Wirth
Status: Resolved Closed
Reply all
Reply to author
Forward
0 new messages