[JIRA] (JENKINS-56605) Cannot use custom agent directive in Jenkinsfile

2019-03-25 Thread rajnic.da...@live.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 David Rajnic commented on  JENKINS-56605  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Cannot use custom agent directive in Jenkinsfile   
 

  
 
 
 
 

 
 Andrew Bayer so there is no other way I can just simply wrap existing agent.docker directive into custom directive? The solution you've proposed seems quite a big for something that is already implemented in docker-plugin  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

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

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[JIRA] (JENKINS-56605) Cannot use custom agent directive in Jenkinsfile

2019-03-18 Thread rajnic.da...@live.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 David Rajnic updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-56605  
 
 
  Cannot use custom agent directive in Jenkinsfile   
 

  
 
 
 
 

 
Change By: 
 David Rajnic  
 

  
 
 
 
 

 
 We are not able to use custom directive for "agent".We'd like to create a set of reusable directives, including few of those replacing the default agent directive. The error thrown is:{code:java}org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:WorkflowScript: 4: Undefined section "nodeAgent" @ line 4, column 5.   nodeAgent(   ^WorkflowScript: 3: Missing required section "agent" @ line 3, column 1.   pipeline {   ^2 errors at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) 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.lambda$doParse$0(CpsGroovyShell.java:135) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:136) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:132) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127) 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:320) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)Finished: FAILURE{code}  And the Jenkinsfile{code:java}@Library('jenkins-pipelines') _pipeline {nodeAgent(version: '10')stages {stage('Build') {...} stage('Test') {...}stage('Publish') {...}}}{code}  We'd like to run this within a docker container with NodeJS \{version}, so for that reason we've decided to create a reusable *nodeAgent* directive.{code:java}def  call(Map opts) {def spec = new NodeAgentSpec(opts)if (!spec.version) {throw new RuntimeException('version must be provided')}new node().  agent( spec)}{code}and for the *node.groovy*{code:java}def agent( NodeAgentSpec spec) {def cacheFolderPath = '$HOME' + "/.docker-cache/node/${spec.version}"sh "mkdir -p ${cacheFolderPath}"sh "chmod 777 -R ${cacheFolderPath}"agent {docker {image "local/nodejs-node-${spec.version}" 

[JIRA] (JENKINS-56605) Cannot use custom agent directive in Jenkinsfile

2019-03-18 Thread rajnic.da...@live.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 David Rajnic created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-56605  
 
 
  Cannot use custom agent directive in Jenkinsfile   
 

  
 
 
 
 

 
Issue Type: 
  Bug  
 
 
Assignee: 
 Unassigned  
 
 
Components: 
 pipeline  
 
 
Created: 
 2019-03-18 18:56  
 
 
Environment: 
 Jenkins ver. 2.168  CentOS 7  
 
 
Priority: 
  Minor  
 
 
Reporter: 
 David Rajnic  
 

  
 
 
 
 

 
 We are not able to use custom directive for "agent". We'd like to create a set of reusable directives, including few of those replacing the default agent directive. The error thrown is: 

 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 4: Undefined section "nodeAgent" @ line 4, column 5.
   nodeAgent(
   ^

WorkflowScript: 3: Missing required section "agent" @ line 3, column 1.
   pipeline {
   ^

2 errors

	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
	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.lambda$doParse$0(CpsGroovyShell.java:135)
	at