[JIRA] (JENKINS-39107) expose "Stream Codeline" as an environment variable

0 views
Skip to first unread message

heiko.nardmann@itechnical.de (JIRA)

unread,
Oct 19, 2016, 8:23:01 AM10/19/16
to jenkinsc...@googlegroups.com
Heiko Nardmann created an issue
 
Jenkins / Improvement JENKINS-39107
expose "Stream Codeline" as an environment variable
Issue Type: Improvement Improvement
Assignee: Unassigned
Attachments: Stream_Codeline.png
Components: p4-plugin
Created: 2016/Oct/19 12:22 PM
Priority: Minor Minor
Reporter: Heiko Nardmann

I retrieve the pipeline script from SCM. See attached screenshot for context.
Now it would be helpful to be able to use the value of (at least) "Stream Codeline" inside my pipeline script.

As far as I understand this is not possible so far?

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

kwirth@perforce.com (JIRA)

unread,
Oct 10, 2018, 6:00:01 AM10/10/18
to jenkinsc...@googlegroups.com
Karl Wirth commented on Improvement JENKINS-39107
 
Re: expose "Stream Codeline" as an environment variable

Still not possible but a possible workaround is to use P4Groovy. For example:

def p4 = p4(credential: 'MyCredential', workspace: staticSpec(charset: 'none', name: env.P4_CLIENT))
def myClient = p4.fetch('client', env.P4_CLIENT)
println ("Stream is: " + myClient.get("Stream") )

The output seen is:

Stream is: //streams/main

 

 

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

pallen@perforce.com (JIRA)

unread,
Oct 11, 2018, 9:42:02 AM10/11/18
to jenkinsc...@googlegroups.com
Paul Allen updated an issue
 
Change By: Paul Allen
Labels: P4_VERIFY P4_BACKLOG

kwirth@perforce.com (JIRA)

unread,
Nov 5, 2018, 8:21:01 AM11/5/18
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
Change By: Karl Wirth
Labels: P4_BACKLOG P4_VERIFY

kwirth@perforce.com (JIRA)

unread,
Nov 5, 2018, 8:21:02 AM11/5/18
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
Change By: Karl Wirth
Priority: Minor Blocker

kwirth@perforce.com (JIRA)

unread,
Nov 5, 2018, 8:37:02 AM11/5/18
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
Change By: Karl Wirth
Labels: P4_VERIFY P4_SUPPORT

kwirth@perforce.com (JIRA)

unread,
Nov 5, 2018, 8:40:02 AM11/5/18
to jenkinsc...@googlegroups.com
 
Re: expose "Stream Codeline" as an environment variable

Reports that this does not work when libraries have been loaded first.

 

e.g.

 

import GLOBAL Lib
...
p4sync

 

Need to confirm with a test case.

 

kwirth@perforce.com (JIRA)

unread,
Nov 5, 2018, 8:40:02 AM11/5/18
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Nov 5, 2018, 10:11:02 AM11/5/18
to jenkinsc...@googlegroups.com
 
Re: expose "Stream Codeline" as an environment variable

Using the following Jenkinsfile the global library is used and the correct stream is derived:

@Library('my-shared-library')
import org.foo.lib.*pipeline {
  agent { label 'Windows10' }
  stages {
    stage("Repro") {
      steps {
        script {
           echo "This library just prints HELLO FROM testFunc version 1."
	   def z = new org.foo.lib()
           z.testFunc()           echo "This shows that the slave contains the correct files with an explicit sync."
	   bat 'dir'
	   bat 'echo WS IS %P4_CLIENT%'
           
	   echo "This tries to get the stream name"
	   def p4 = p4(credential: 'JenkinsMaster', workspace: staticSpec(charset: 'none', name: env.P4_CLIENT))
	   def myClient = p4.fetch('client', env.P4_CLIENT)
	   println ("Stream is: " + myClient.get("Stream") )
        }
      }
    }
  }
}

This results in:

--- cut ---
P4 Task: syncing files at change: 25
... p4 sync -q C:\filestore\Jenkins\workspace\Pipeline/...@25
 +
duration: (139ms)P4 Task: saving built changes.
... p4 client -o jenkinsTemp-fb4e3cb9-0625-4a97-b83b-f9003f7e4cc4 +
... p4 info +
... p4 info +
... p4 client -i +
... done[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Repro)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
This library just prints HELLO FROM testFunc version 1.
[Pipeline] echo
HELLO FROM testFunc version 1
[Pipeline] echo
This shows that the slave contains the correct files with an explicit sync.
[Pipeline] bat
[Pipeline] Running batch scriptC:\filestore\Jenkins\workspace\Pipeline>dir
 Volume in drive C has no label.
 Volume Serial Number is 8EBB-387C Directory of C:\filestore\Jenkins\workspace\Pipeline05/11/2018  15:07    <DIR>          .
05/11/2018  15:07    <DIR>          ..
05/11/2018  15:07               752 Jenkinsfile
05/11/2018  15:07    <DIR>          libs
05/11/2018  15:07                14 test.c
05/11/2018  15:07                14 test.h
05/11/2018  15:07                14 test1.c
05/11/2018  15:07                14 test1.h
               5 File(s)            808 bytes
               3 Dir(s)  82,407,059,456 bytes free
[Pipeline] bat
[Pipeline] Running batch scriptC:\filestore\Jenkins\workspace\Pipeline>echo WS IS jenkinsTemp-fb4e3cb9-0625-4a97-b83b-f9003f7e4cc4 
WS IS jenkinsTemp-fb4e3cb9-0625-4a97-b83b-f9003f7e4cc4
[Pipeline] echo
This tries to get the stream name
[Pipeline] p4
[Pipeline] echo
Stream is: //streams/main
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

daniel.hoerner@vyaire.com (JIRA)

unread,
Nov 6, 2018, 3:51:35 AM11/6/18
to jenkinsc...@googlegroups.com

I have tried with the "node" element and this does not work. No files are synced!

 

 

@Library('my-shared-library')
import org.foo.lib.*pipeline {
  node{ 'Windows10' }
    stage("Repro") {
           echo "This library just prints HELLO FROM testFunc version 1."
	   def z = new org.foo.lib()
           z.testFunc()           echo "This shows that the slave contains the correct files with an explicit sync."
	   bat 'dir'
	   bat 'echo WS IS %P4_CLIENT%'
           
	   echo "This tries to get the stream name"
	   def p4 = p4(credential: 'JenkinsMaster', workspace: staticSpec(charset: 'none', name: env.P4_CLIENT))
	   def myClient = p4.fetch('client', env.P4_CLIENT)
	   println ("Stream is: " + myClient.get("Stream") )
  }
}

daniel.hoerner@vyaire.com (JIRA)

unread,
Nov 6, 2018, 3:52:01 AM11/6/18
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Nov 6, 2018, 12:53:02 PM11/6/18
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
Change By: Karl Wirth
Labels: P4_SUPPORT P4_VERIFY

kwirth@perforce.com (JIRA)

unread,
Nov 6, 2018, 12:53:02 PM11/6/18
to jenkinsc...@googlegroups.com
Karl Wirth commented on Improvement JENKINS-39107
 
Re: expose "Stream Codeline" as an environment variable

Confirmation that the workaround is not valid when using scripted pipeline. Scripted pipeline does not do the implicit sync so P4CLIENT is either null or if using global libraries the temporary client for the global library.

However as P4CLIENT is not set it's questionable if 'P4_STREAM' (if it existed) would be availble until 'p4sync' is invoked which would need to know the STREAM name to run.

msmeeth@perforce.com (JIRA)

unread,
Nov 14, 2018, 6:27:02 AM11/14/18
to jenkinsc...@googlegroups.com

pallen@perforce.com (JIRA)

unread,
Jan 17, 2019, 9:57:02 AM1/17/19
to jenkinsc...@googlegroups.com
Paul Allen assigned an issue to Unassigned
Change By: Paul Allen
Assignee: Karl Wirth

pallen@perforce.com (JIRA)

unread,
Jan 17, 2019, 10:05:03 AM1/17/19
to jenkinsc...@googlegroups.com
Paul Allen commented on Improvement JENKINS-39107
 
Re: expose "Stream Codeline" as an environment variable

Might be able to store the Perforce Depot path to the Jenkinsfile.  (Need to consider lightweight checkout where no client is used)

pallen@perforce.com (JIRA)

unread,
Jan 17, 2019, 10:05:04 AM1/17/19
to jenkinsc...@googlegroups.com

cbopardikar@perforce.com (JIRA)

unread,
Jan 23, 2019, 5:02:01 AM1/23/19
to jenkinsc...@googlegroups.com
Charusheela Bopardikar started work on Improvement JENKINS-39107
 
Change By: Charusheela Bopardikar
Status: Open In Progress

cbopardikar@perforce.com (JIRA)

unread,
Jan 25, 2019, 11:00:02 AM1/25/19
to jenkinsc...@googlegroups.com
Charusheela Bopardikar stopped work on Improvement JENKINS-39107
 
Change By: Charusheela Bopardikar
Status: In Progress Open

cbopardikar@perforce.com (JIRA)

unread,
Jan 25, 2019, 11:01:03 AM1/25/19
to jenkinsc...@googlegroups.com
Charusheela Bopardikar updated Improvement JENKINS-39107
 

Please review

Change By: Charusheela Bopardikar
Status: Open Fixed but Unreleased
Resolution: Fixed

cbopardikar@perforce.com (JIRA)

unread,
Jan 25, 2019, 11:02:02 AM1/25/19
to jenkinsc...@googlegroups.com
Charusheela Bopardikar edited a comment on Improvement JENKINS-39107
 
Re: expose "Stream Codeline" as an environment variable
Please review jenkinsfile path is stored as env variable irrespective of streams

cbopardikar@perforce.com (JIRA)

unread,
Jan 25, 2019, 11:03:02 AM1/25/19
to jenkinsc...@googlegroups.com
Exposed jenkinsfile path is stored as env variable irrespective of streams

cbopardikar@perforce.com (JIRA)

unread,
Feb 12, 2019, 5:48:04 AM2/12/19
to jenkinsc...@googlegroups.com

cbopardikar@perforce.com (JIRA)

unread,
Feb 12, 2019, 5:48:05 AM2/12/19
to jenkinsc...@googlegroups.com

cbopardikar@perforce.com (JIRA)

unread,
Feb 12, 2019, 5:48:06 AM2/12/19
to jenkinsc...@googlegroups.com

cbopardikar@perforce.com (JIRA)

unread,
Feb 12, 2019, 5:48:07 AM2/12/19
to jenkinsc...@googlegroups.com
Charusheela Bopardikar started work on Improvement JENKINS-39107
 
Change By: Charusheela Bopardikar
Status: Open In Progress

cbopardikar@perforce.com (JIRA)

unread,
Feb 12, 2019, 5:48:07 AM2/12/19
to jenkinsc...@googlegroups.com

pallen@perforce.com (JIRA)

unread,
Feb 14, 2019, 9:27:02 AM2/14/19
to jenkinsc...@googlegroups.com
Paul Allen updated Improvement JENKINS-39107
 

Ready for release

Change By: Paul Allen
Status: In Review Resolved
Resolution: Fixed

daniel.hoerner@vyaire.com (JIRA)

unread,
Mar 27, 2019, 3:37:02 AM3/27/19
to jenkinsc...@googlegroups.com
Daniel Hoerner commented on Improvement JENKINS-39107
 
Re: expose "Stream Codeline" as an environment variable

 this bug already fixed in the P4 plugin Version 1.9.6

daniel.hoerner@vyaire.com (JIRA)

unread,
May 20, 2019, 3:26:02 AM5/20/19
to jenkinsc...@googlegroups.com
Daniel Hoerner reopened an issue
 

This feature does not work as expected.

ff you have a global library import, the variable "JENKINSFILE_PATH" contains the path to the global library + "/Jenkinsfile"

Change By: Daniel Hoerner
Resolution: Fixed
Status: Resolved Reopened

cbopardikar@perforce.com (JIRA)

unread,
Jun 5, 2019, 5:56:02 AM6/5/19
to jenkinsc...@googlegroups.com
Charusheela Bopardikar commented on Improvement JENKINS-39107
 
Re: expose "Stream Codeline" as an environment variable

Tried different ways with a multibranch pipeline using global library and Jenkinsfile. Here are the findings:

If the Jenkinsfile is doing a skipDefaultCheckout, the JENKINSFILE_PATH will not be set. This is observed irrespective of whether the pipeline uses global library or not.

If the pipeline uses global library without skipDefaultCheckout, the JENKINSFILE_PATH environment variable will be set.

 

cbopardikar@perforce.com (JIRA)

unread,
Jun 6, 2019, 5:07:02 AM6/6/19
to jenkinsc...@googlegroups.com
Tried different ways with a multibranch pipeline using global library and Jenkinsfile. Here are the findings:

If the Jenkinsfile is doing a skipDefaultCheckout, the JENKINSFILE_PATH will is not be set. This is observed irrespective of whether the pipeline uses global library or not.

If the pipeline uses global library without skipDefaultCheckout, the JENKINSFILE_PATH environment variable
will be is set correctly .

 

pallen@perforce.com (JIRA)

unread,
Oct 2, 2019, 7:19:05 AM10/2/19
to jenkinsc...@googlegroups.com
Paul Allen started work on Improvement JENKINS-39107
 
Change By: Paul Allen
Status: Reopened In Progress
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

daniel.hoerner@vyaire.com (JIRA)

unread,
Nov 18, 2019, 10:03:09 AM11/18/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages