jenkinsci / plasticscm-plugin

A plugin for Jenkins to be able to use Plastic SCM
MIT License
16 stars 31 forks source link

Exposed Environment varibles don't show #8

Closed ex4p closed 6 years ago

ex4p commented 7 years ago

version 2.9

If in a build I execute this shell:

!C:\Perl64\bin\perl.exe -w

print "Environment Variables:\n"; foreach $key (sort(keys %ENV)) { print "$key = $ENV{$key}\n"; } print "Done.\n";

it shows all environment variables except the plastic ones.

I also tried batch commands:

echo %PLASTICSCM_REPSPEC% echo %PLASTICSCM_BRANCH% echo %PLASTICSCM_AUTHOR% echo %WORKSPACE%

WORKSPACE shows but none of the plastic variables show.

ex4p commented 7 years ago

Here is the output of the perl script. Lots of variables but no plastic variables. Environment Variables: ALLUSERSPROFILE = C:\ProgramData APPDATA = C:\windows\system32\config\systemprofile\AppData\Roaming BASE = C:\Program Files (x86)\Jenkins BUILD_DISPLAY_NAME = #11 BUILD_ID = 11 BUILD_NUMBER = 11 BUILD_TAG = jenkins-plastic1-11 BUILD_URL = http://localhost:8080/job/plastic1/11/ COMMONPROGRAMFILES = C:\Program Files\Common Files COMMONPROGRAMFILES(X86) = C:\Program Files (x86)\Common Files COMMONPROGRAMW6432 = C:\Program Files\Common Files COMPUTERNAME = ** COMSPEC = C:\windows\system32\cmd.exe DEFLOGDIR = C:\ProgramData\McAfee\DesktopProtection DEPLOYMENT.EXPIRATION.CHECK.ENABLED = false EXECUTOR_NUMBER = 0 FP_NO_HOST_CHECK = NO HUDSON_COOKIE = 469690c5-5f5c-4076-87d7-cca86ddb66fc HUDSON_HOME = C:\Program Files (x86)\Jenkins HUDSON_SERVER_COOKIE = 418fb500ec0f5c8c HUDSON_URL = http://localhost:8080/ JENKINS_HOME = C:\Program Files (x86)\Jenkins JENKINS_SERVER_COOKIE = 418fb500ec0f5c8c JENKINS_URL = http://localhost:8080/ JOB_BASE_NAME = plastic1 JOB_DISPLAY_URL = http://localhost:8080/job/plastic1/display/redirect JOB_NAME = plastic1 JOB_URL = http://localhost:8080/job/plastic1/ LOCALAPPDATA = C:\windows\system32\config\systemprofile\AppData\Local MEETINGCENTERAPP = C:\Program Files (x86)\InterCall Unified Meeting\ NODE_LABELS = master NODE_NAME = master NUMBER_OF_PROCESSORS = 4 OS = Windows_NT PATH = C:\Program Files\PlasticSCM5\client;C:\ProgramData\Oracle\Java\javapath;C:\Perl64\site\bin;C:\Perl64\bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin; PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE = AMD64 PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 58 Stepping 9, GenuineIntel PROCESSOR_LEVEL = 6 PROCESSOR_REVISION = 3a09 PROGRAMDATA = C:\ProgramData PROGRAMFILES = C:\Program Files PROGRAMFILES(X86) = C:\Program Files (x86) PROGRAMW6432 = C:\Program Files PSMODULEPATH = C:\windows\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC = C:\Users\Public RUN_CHANGES_DISPLAY_URL = http://localhost:8080/job/plastic1/11/display/redirect?page=changes RUN_DISPLAY_URL = http://localhost:8080/job/plastic1/11/display/redirect SERVICE_ID = Jenkins SYSTEMDRIVE = C: SYSTEMROOT = C:\windows TEMP = C:\windows\TEMP TMP = C:\windows\TEMP UATDATA = C:\windows\SysWOW64\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77 USERDOMAIN = * USERNAME = *****$ USERPROFILE = C:\windows\system32\config\systemprofile VSEDEFLOGDIR = C:\ProgramData\McAfee\DesktopProtection WINDIR = C:\windows WINDOWS_TRACING_FLAGS = 3 WINDOWS_TRACING_LOGFILE = C:\BVTBin\Tests\installpackage\csilogfile.log WINSW_EXECUTABLE = C:\Program Files (x86)\Jenkins\jenkins.exe WINSW_SERVICE_ID = Jenkins WORKSPACE = C:\Program Files (x86)\Jenkins\workspace\plastic1 Done.

ghost commented 7 years ago

I also see this behaviour. Looking at the source code, I think it may be because the class PlasticSCM overrides buildEnvVars which according to here (http://javadoc.jenkins-ci.org/hudson/scm/SCM.html) is deprecated. I think it should be changed to buildEnvironment?

mig42 commented 6 years ago

Hi all,

It might be something windows related, as we successfully consumed the Plastic SCM build environment variables in a simple script like this one:

image

@KieranFabrik We'll have a look at your suggestion so see if it might be the solution to this issue.

miryamGSM commented 6 years ago

Hi all,

A new release of Plastic/Jenkins plugin with the fix is already available (2.13). https://plugins.jenkins.io/plasticscm-plugin

Thanks for the report.

Best regards, Míryam

tombradshaw2001 commented 6 years ago

Hi, I have upgraded to 2.15, but I can't get a values for PLASTICSCM_CHANGESET_ID (and others)? I was looking to use the value in a Batch command as part of the build if thats possible? Should this environment value exist? Thanks

tombradshaw2001 commented 6 years ago

Hi, I have partly answered my own question, seems the changes are recorded, so if the changeset is the same, that is you just build the same changeset then the XML in the build log is this:

so it seems PLASTICSCM_CHANGESET_ID etc. wont be populated. if the branch has a new changeset the XML will be populated and hence PLASTICSCM_CHANGESET_ID. I guess this is ok, as I was learning/developing Jenkins setup I kept building the same branch changeset so got the empty environment. I will need to investigate some more. Tom

miryamGSM commented 6 years ago

Hi Tom,

I checked it with 2.15 version and it works fine for me.

Below is a sample of the console output for a build without new changes:

console-output

This is the configuration for my project which contains configured environment variables:

project-configuration

Hope it helps!

Please do not hesitate to contact us if you have any issue.

Best regards, Míryam

tombradshaw2001 commented 6 years ago

Hi, so if you repeatedly build the same branch/changeset number you always get PLASTICSCM_CHANGESET_ID ?

miryamGSM commented 6 years ago

Hi Tom,

Yes.

Maybe some configuration issue. Do you mind sharing with us screenshots of the configuration you use?

We basically need all the job creation steps in order to see if we are missing something.

You can send the information to support at codicesoftware dot com.

Thanks in advance, Míryam

tombradshaw2001 commented 6 years ago

Hi, thanks for the input, I did think I had this working yesterday, and it turns out a colleague downgraded back to 2.7 this morning. I am in UK, he is based in Poland so there was a delay in communications! He downgraded because of an error

"Searching for changed items in the workspace... The workspace cannot be updated since there are pending changes. Please review the pending changes and retry the operation again. FATAL: The cm command 'update' failed after 3 retries"

I got this as well, I think he is going to contact you about it. Thanks Tom

miryamGSM commented 6 years ago

Hi Tom,

Ok. We are already in contact with your colleague in order to solve the issue related to the update command ;)

Best regards, Míryam

pmahony893 commented 5 years ago

Hello,

I've run into exactly the same issue (using v2.20), and after spending most of the day reading the plugin's source code (and Jenkins'), I think I've narrowed down the conditions for reproducing this bug.

In order to find changeset information, the plugin looks at the changesets since the last build. If there are none, it looks at the build before to get its changeset data, and then the build before, and so on. If there is no previous build, no changeset information is used.

This means that the first build of the project will never have the changeset information injected, and if there are no changesets since the first build, no changeset information will be injected into the environment.

It would be great if this could be fixed - it caused us considerable frustration in trying to set up a couple of new Jenkins projects. Let me know if you need any more help reproducing the issue.

Thanks, Peter