Re: Groovy and Token Macro support for Email-ext

2018-10-08 Thread Elisha Greenwald
Dude. You're the man! That would be awesome to get the tokens working in
pipeline.

Thanks!

On Mon, Oct 8, 2018 at 1:57 PM Slide  wrote:

> The default templates have some information about getting info from
> changesets and so forth, you could look at those:
>
>
> https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template#L88
>
>
> https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template#L101
>
> I also opened a PR to the plugin to allow the tokens to work in groovy
> scripts:
>
> https://github.com/jenkinsci/email-ext-plugin/pull/173
>
>
>
> On Sun, Oct 7, 2018 at 9:03 PM Elisha Greenwald 
> wrote:
>
>> Thanks so much for looking. Really appreciate it. Any idea how to get the
>> git commit hash some other way? I've tried a bunch to no avail...
>>
>> On Sun, Oct 7, 2018, 11:26 PM Slide  wrote:
>>
>>> Ok, I took a look at the source and it will definitely not work as is
>>> right now. The plugin in this one case is still assuming AbstractBuild
>>> instead of Run.
>>>
>>> On Fri, Oct 5, 2018 at 3:41 PM Slide  wrote:
>>>
 Ok, I didn't realize you were doing this from a pipeline job (maybe I
 missed that). I am not sure how it will work with pipeline right now, I
 need to review the code.

 On Fri, Oct 5, 2018 at 1:48 PM  wrote:

> Just to add to that:
>
> If I do within groovy brackets %> <%
>
> I get the following exception:
> Exception raised during template rendering:
> org.jenkinsci.plugins.workflow.job.WorkflowRun cannot be cast to
> hudson.model.AbstractBuild java.lang.ClassCastException:
> org.jenkinsci.plugins.workflow.job.WorkflowRun cannot be cast to
> hudson.model.AbstractBuild at
> hudson.plugins.emailext.plugins.content.EmailExtScript.methodMissing(EmailExtScript.java:69)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498) at
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) 
> at
> groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:944) at
> groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1267)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1220) at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
> at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
> at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
> at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
> at SimpleTemplateScript111.run(SimpleTemplateScript111.groovy:31) at
> groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168)
> at
> groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180)
> at
> hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:151)
> at
> hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:82)
> at
> org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:208)
> at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser.java:308) 
> at
> org.jenkinsci.plugins.tokenmacro.Action$KiHW1UeqOdqAwZul.run(Unknown
> Source) at
> org.parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) at
> org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
> at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
> org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at
> org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
> at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
> org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at
> org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
> at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
> org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at
> org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
> at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
> org.parboiled.matchers.ZeroOrMoreMatcher.match(ZeroOrMoreMatcher.java:39)
> at
> org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
> at 

Re: Groovy and Token Macro support for Email-ext

2018-10-08 Thread Slide
The default templates have some information about getting info from
changesets and so forth, you could look at those:

https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template#L88

https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template#L101

I also opened a PR to the plugin to allow the tokens to work in groovy
scripts:

https://github.com/jenkinsci/email-ext-plugin/pull/173



On Sun, Oct 7, 2018 at 9:03 PM Elisha Greenwald 
wrote:

> Thanks so much for looking. Really appreciate it. Any idea how to get the
> git commit hash some other way? I've tried a bunch to no avail...
>
> On Sun, Oct 7, 2018, 11:26 PM Slide  wrote:
>
>> Ok, I took a look at the source and it will definitely not work as is
>> right now. The plugin in this one case is still assuming AbstractBuild
>> instead of Run.
>>
>> On Fri, Oct 5, 2018 at 3:41 PM Slide  wrote:
>>
>>> Ok, I didn't realize you were doing this from a pipeline job (maybe I
>>> missed that). I am not sure how it will work with pipeline right now, I
>>> need to review the code.
>>>
>>> On Fri, Oct 5, 2018 at 1:48 PM  wrote:
>>>
 Just to add to that:

 If I do within groovy brackets %> <%

 I get the following exception:
 Exception raised during template rendering:
 org.jenkinsci.plugins.workflow.job.WorkflowRun cannot be cast to
 hudson.model.AbstractBuild java.lang.ClassCastException:
 org.jenkinsci.plugins.workflow.job.WorkflowRun cannot be cast to
 hudson.model.AbstractBuild at
 hudson.plugins.emailext.plugins.content.EmailExtScript.methodMissing(EmailExtScript.java:69)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498) at
 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at
 groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:944) at
 groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1267)
 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1220) at
 groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027) at
 org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
 at
 org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
 at
 org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
 at
 org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
 at SimpleTemplateScript111.run(SimpleTemplateScript111.groovy:31) at
 groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168)
 at
 groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180)
 at
 hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:151)
 at
 hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:82)
 at
 org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:208)
 at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser.java:308) at
 org.jenkinsci.plugins.tokenmacro.Action$KiHW1UeqOdqAwZul.run(Unknown
 Source) at
 org.parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) at
 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
 at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
 org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at
 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
 at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
 org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at
 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
 at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
 org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at
 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
 at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
 org.parboiled.matchers.ZeroOrMoreMatcher.match(ZeroOrMoreMatcher.java:39)
 at
 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
 at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at
 org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at
 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77)
 at 

Using @grab to fetch SNAPSHOT jar in groovy sometimes can't be recoganized correctly if updating the SNAPSHOT

2018-10-08 Thread pan
Hi,

I got an issue when using @grab.
We are developing a jar and pipeline script to do the CI. We modify some 
java code, deploy onto our internal Nexus server, use @grab in groovy to 
fetch it to call the function.
During developing, we found when we modify some code, deploy a new SNAPSHOT 
version with the same version number of jar, sometimes the pipeline script 
is not working.

For example:

@GrabResolver(name='Internal Nexus Snapshot', 
> root='https://internal.nexus.com/')
> @Grab('some-package:some-artifact:0.0.1-SNAPSHOT')
> import some.Utils
> println new Utils()


It works well, but if I deploy a new version to Nexus, it might fail, 
unless I restart the Jenkins, then it will work again.

error message:

Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 1: unable to resolve class some.Utils
 @ line 1, column 1.
   @GrabResolver(name='Internal Nexus Snapshot', 
root='https://internal.nexus.com/')
   ^

1 error

at 
org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at 
org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:958)
at 
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)
at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:554)
at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at 
org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:131)
at 
org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:125)
at 
org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:560)
at 
org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:521)
at 
org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:290)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Finished: FAILURE



I think it might be some cache in Jenkins, because restart Jenkins will fix 
it. But I can't find it.
Does anyone have any clue about this?
Thank you very much.


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/56f3398c-9d7c-4192-96d1-bedaf7fb4adf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Configure Linux and Windows slave node

2018-10-08 Thread Pavel Novák
Hi,
there is a link with which describes step by step, how to add the agent , 
new node 
https://linuxacademy.com/blog/devops/adding-a-jenkins-agent-node/

It seems to be possible add it via pipeline as well
https://support.cloudbees.com/hc/en-us/articles/218154667-Create-a-Permanent-Agent-from-Groovy-Console

launch methods are:
- via ssh
- via webstart
- via execution command on master
- control windows slave as windows service

I have linux slaves made by ssh access and windows via webstart, eg. 

Dne čtvrtek 4. října 2018 15:35:53 UTC+2 gotvi...@gmail.com napsal(a):
>
> What are the methods to configure a Linux and Windows slave node?
>
> Is there a runbook for it?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4b7a213c-1a59-4555-9d2e-f5b02cb76091%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get workspace folder content of EACH slave nodes?

2018-10-08 Thread 'Xiaocheng Wang' via Jenkins Users
Currently we have to SSH to each slave node and get the workspace folder 
content, but this is not acceptable due to internal security reasons.

Is there a way to get it from Jenkins directly? Or from Java code?


On Friday, September 28, 2018 at 5:41:46 PM UTC+8, Xiaocheng Wang wrote:
>
> Hello Jenkins experts,
>
> We have deployed 1 Jenkins master node + 3 slave node. Jobs are building 
> on different slaves. We need to get the workspace folder content of each 
> running build in realtime, so that to acquire additional build progress 
> details.
>
> We tried to get this info by URL "
> *http://:/job//ws*", however it 
> only displays workspace content of slave node which runs the latest build. 
> If 2 jobs are running in parallel on different slave, we are unable to get 
> the first one's workspace content by that URL.
>
> Could you please kindly give some proposal?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a1e3e6d0-8e34-4dbf-97a0-cec07a7423de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.