I'm using Saltstack plugin (https://github.com/jenkinsci/saltstack-plugin) 
in the pipeline. The plugin has an option to return output 
into SALTBUILDOUTPUT variable.

Although the plugin is not listed as pipeline compatible, it nevertheless 
works i.e. I'm able to run it using pipeline:
-----------------------------------------
node {
  salt authtype: 'pam', clientInterface: local(arguments: 'xxx', 
blockbuild: true, function: 'grains.get', target: 'atarget', targetType: 
'glob'), credentialsId: '497b...', saveEnvVar: true, servername: 
'http://172....'

println("SALTBUILDOUTPUT 1 = ${env.SALTBUILDOUTPUT}")
printf("SALTBUILDOUTPUT 3 = %s\n", env)
}
-----------------------------------------

The output:
-----------------------------------------
Running jid: 20170215152138504719
....
SALTBUILDOUTPUT 1 = null
SALTBUILDOUTPUT 3 = 
org.jenkinsci.plugins.workflow.cps.EnvActionImpl@1765f04e
...
-----------------------------------------

The plugin uses a standard method to set the variable by implementing 
"EnvironmentContributingAction.buildEnvVars" in "class PublishEnvVarAction 
extends InvisibleAction implements EnvironmentContributingAction".

Here is a snippet where it is called:
-----------------------------------------
public boolean perform(Run build,...) {
...
        if (saveEnvVar) {
            build.addAction(new PublishEnvVarAction("SALTBUILDOUTPUT", 
returnArray.toString()));
            build.getEnvironment(listener);
        }
...
}
------------------------------------------
I ran the plugin in the debugger and attest the snippet above was called as 
expected. 
On the other hand 'buildEnvVars' has never been called i.e. the breakpoint 
was never hit. Consequently the SALTBUILDOUTPUT remained NULL.
-----------------------------------------

I used a few versions of Jenkins while debugging including one built from 
Git (2.47-SNAPSHOT)

I also built the Saltstack plugin from sources with parent 
"org.jenkins-ci.plugins/plugin/2.20". Note that plugin has an obvious bug. 
It tries to readdress returnArray parameter within the scope of the called 
method, so that after the call returns all the information in returnArray 
is lost. I fixed the bug and the job returns output OK i.e. 
"returnArray.toString()" above returns information that can be seen in the 
debugger and is also printed by Jenkins into the log.

I suspect that some changes in Jenkins API rendered 
"EnvironmentContributingAction.buildEnvVars" useless. This is NOT a 
Saltstack plugin problem.

Please, help with resolving this.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/560d8a8c-ce4a-4fee-9351-fbbc9aba6e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to