[JIRA] (JENKINS-58952) sh labels can't be used in post stages

0 views
Skip to first unread message

brian.murrell@intel.com (JIRA)

unread,
Aug 15, 2019, 10:38:03 AM8/15/19
to jenkinsc...@googlegroups.com
Brian J Murrell created an issue
 
Jenkins / Bug JENKINS-58952
sh labels can't be used in post stages
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline-build-step-plugin
Created: 2019-08-15 14:37
Priority: Major Major
Reporter: Brian J Murrell

When I try to assign a label to an sh step in a post stage I get an error. I.e.:

                    post {
                       always {
                            sh label: "Collect artifacts and tear down",
                               script '''set -ex

I get the error:

WorkflowScript: 1078: Expected a step @ line 1078, column 29.
                               sh label: "Collect artifacts and tear down",
                               ^

This works in a build step though:

                stage('Build') {
                    when {
                        beforeAgent true
                        expression { return env.QUICKBUILD == '1' }
                    }
                    agent {
                        dockerfile {
                            filename 'Dockerfile'
                            dir 'utils/docker'
                            label 'docker_runner'
                            additionalBuildArgs '--build-arg UID=$(id -u) --build-arg JENKINS_URL=' +
                                                env.JENKINS_URL +
                                                 " --build-arg CACHEBUST=${currentBuild.startTimeInMillis}"
                        }
                    }
                    steps {
                         githubNotify credentialsId: 'daos-jenkins-commit-status',
                                      description: env.STAGE_NAME,
                                      context: "build" + "/" + env.STAGE_NAME,
                                      status: "PENDING"
                        checkoutScm withSubmodules: true
                        catchError(stageResult: 'UNSTABLE', buildResult: 'SUCCESS') {
                            sh label: env.STAGE_NAME,
                               script: '''rm -rf artifacts/sles12.3/

 

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

brian.murrell@intel.com (JIRA)

unread,
Aug 15, 2019, 10:43:02 AM8/15/19
to jenkinsc...@googlegroups.com
Brian J Murrell commented on Bug JENKINS-58952
 
Re: sh labels can't be used in post stages

If I put the label after the script

                            sh script: '''set -ex
                                      ...''',
                            label: "Collect artifacts and tear down"

it parses fine.

Reply all
Reply to author
Forward
0 new messages