Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58952

sh labels can't be used in post stages


      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/


            Unassigned Unassigned
            brianjmurrell Brian J Murrell
            0 Vote for this issue
            1 Start watching this issue