[JIRA] (JENKINS-49662) Ability to create custom stages in parallel blocks in pipeline shared library

1 view
Skip to first unread message

kevin.lannen@gmail.com (JIRA)

unread,
Feb 20, 2018, 5:47:03 PM2/20/18
to jenkinsc...@googlegroups.com
Kevin Lannen created an issue
 
Jenkins / New Feature JENKINS-49662
Ability to create custom stages in parallel blocks in pipeline shared library
Issue Type: New Feature New Feature
Assignee: Unassigned
Components: pipeline
Created: 2018-02-20 22:46
Priority: Minor Minor
Reporter: Kevin Lannen

I would like to be able to easily run the same steps across multiple nodes using the declarative pipeline and a shared library. This does not currently seem to be possible since only custom steps can be created in shared libraries.

 

Example jenkinsfile:

pipeline {
    agent any
    stages {
        stage('Build everywhere') {
            runOnAllPlatforms {
                sh 'doing build things'
            }
        }
    }
}

Example shared library vars/runOnAllPlatforms.groovy:

def call(Closure body) {
    parallel {
        stage('RHEL') {
            agent {
                node { label 'rhel7' }
            }
            steps {
                body()
            }
        stage('Apple') {
        agent {
            node { label 'apple' }
        }
        steps {
            body()
        }
        steps {
            body()
        }
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2018, 10:49:03 AM2/21/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Component/s: pipeline-model-definition-plugin
Component/s: pipeline

andrew.bayer@gmail.com (JIRA)

unread,
Mar 8, 2018, 6:31:03 PM3/8/18
to jenkinsc...@googlegroups.com
Andrew Bayer resolved as Duplicate
Change By: Andrew Bayer
Status: Open Resolved
Resolution: Duplicate

marcello_desales@intuit.com (JIRA)

unread,
May 10, 2018, 8:18:03 PM5/10/18
to jenkinsc...@googlegroups.com
Marcello de Sales commented on New Feature JENKINS-49662
 
Re: Ability to create custom stages in parallel blocks in pipeline shared library

Kevin Lannen I'm getting the following error: ": Starting with version 0.5, steps in a stage must be in a steps block.

Any reason why? I'm reusing your example...

pipeline {

  agent any

  stages {

    stage('Build everywhere') {
     runOnAllPlatforms {
       sh 'doing build things'
     }
  }
}

 

The error is the following:

 

 

Branch indexing
Connecting to https://github.intuit.com/api/v3 using mdesales/****** (GitHub Enterprise Access Token)
Obtained Jenkinsfile from 3d42560bb3044468f1acd3c75f1d904e5df15247
Running in Durability level: MAX_SURVIVABILITY

GitHub has been notified of this commit’s build result

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 9: Unknown stage section "runOnAllPlatforms". Starting with version 0.5, steps in a stage must be in a steps block. @ line 9, column 5.
       stage('Build everywhere') {
       ^

WorkflowScript: 9: No "steps" or "parallel" to execute within stage "Build everywhere" @ line 9, column 5.
       stage('Build everywhere') {
       ^

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.doParse(CpsGroovyShell.java:133)
	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:557)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:518)
	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:429)
Finished: FAILURE

 

kevin.lannen@gmail.com (JIRA)

unread,
May 10, 2018, 8:40:02 PM5/10/18
to jenkinsc...@googlegroups.com

Yes, there's a very good reason why the code won't work. I wrote that code to demonstrate what how I would like the API to work as a feature request, not as code that currently works hence why this feature request exists.

marcello_desales@intuit.com (JIRA)

unread,
May 10, 2018, 8:42:02 PM5/10/18
to jenkinsc...@googlegroups.com

marcello_desales@intuit.com (JIRA)

unread,
May 10, 2018, 8:42:02 PM5/10/18
to jenkinsc...@googlegroups.com

kevin.lannen@gmail.com (JIRA)

unread,
May 10, 2018, 8:51:01 PM5/10/18
to jenkinsc...@googlegroups.com

This functionality is available with the scripted syntax if that's what you are trying to do though.

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:58 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Duplicate
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages