[JIRA] (JENKINS-43820) Stage name must be a string literal

49 views
Skip to first unread message

kevin.lannen@gmail.com (JIRA)

unread,
Mar 16, 2018, 2:31:02 PM3/16/18
to jenkinsc...@googlegroups.com
Kevin Lannen commented on Bug JENKINS-43820
 
Re: Stage name must be a string literal

This is a serious blocker to using the declarative syntax to define a pipeline in a shared library. What is the "conscious design decision" that led to this? From my perspective there is no downside to allowing this flexibility.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

nimrod7@gmail.com (JIRA)

unread,
Jun 15, 2018, 11:23:01 AM6/15/18
to jenkinsc...@googlegroups.com

Andrew Bayer please explain why it's not possible. Now I am not able to reuse stages, because I must hardcode the text.

thiago.davila@serpro.gov.br (JIRA)

unread,
Jul 11, 2018, 2:13:02 PM7/11/18
to jenkinsc...@googlegroups.com

Andrew Bayer what is the recommended workaround to generate stages at runtime? I'm developing template stages in shared-libraries and wanted to create a stagename passed by parameter. If this is a design decision there must be a recommended way, or it imposes limitations to the use of declarative pipelines.

This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

jeezusjr@gmail.com (JIRA)

unread,
Aug 10, 2018, 12:28:02 AM8/10/18
to jenkinsc...@googlegroups.com

This is a silly "conscious design decision" as it eliminates the possibilities of stage names generated from dynamic variables.
 

environment {
   BUILD = "Release"
}
stage ("Building ${BUILD}") {
  steps {
    // blah
  }
}

In order to get this to work I have to drop the stage in a pipeline library. This sucks!

I guess i'll have to live with my ghetto fix:

environment {
   BUILD = "Release"
}
stage ("Building}") {
  steps {
    println "${BUILD} branch, this extra line is crap"
    // blah
  }
}

nico.mommaerts@gmail.com (JIRA)

unread,
Aug 23, 2018, 9:58:02 AM8/23/18
to jenkinsc...@googlegroups.com

Conscious decision? Let the users decide how to use the system... in a world of job-dsl, automation, devops etc this a serious blocker. Please reconsider this.

marcello.romani.enit@gmail.com (JIRA)

unread,
Nov 7, 2018, 9:10:04 AM11/7/18
to jenkinsc...@googlegroups.com

Andrew Bayer, do you have a pointer to documentation that explains this limitation?

I know this has been asked before, but it looks like quite an annoying shortcoming.

Thanks!

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

socialguy@outlook.com (JIRA)

unread,
Dec 4, 2018, 4:15:03 PM12/4/18
to jenkinsc...@googlegroups.com

Andrew Bayer once you get off your high horse, please consider fixing what was clearly pulled out of a hat.

adam@diginc.us (JIRA)

unread,
Mar 25, 2019, 5:56:02 PM3/25/19
to jenkinsc...@googlegroups.com
Adam BH commented on Bug JENKINS-43820

Since no response is being made by CloudBees my best guess is they wanted to encourage static stage names because the legacy build history (not BO, maybe others too) view shows history best when stages don't change names dynamically. Anyone who has ever changed stages over time knows their history on this view gets reset when doing.

My use case for this wasn't to change the stage name(s) between builds but just to avoid some repeated strings with a variable used by a bool parameter (the key, not value), my label, and my stage name. I'll echo others, this feels rather arbitrary and the silence is more frustrating than 'No because X'...the key part being 'because X'.

HighlandLogan@JohnDeere.com (JIRA)

unread,
Mar 26, 2019, 4:31:02 PM3/26/19
to jenkinsc...@googlegroups.com

Andrew Bayer I would also appreciate the reasoning behind this decision. It seems that for an unknown reason you are not implementing something that would be very helpful, and any explanation as to why this isn't feasible would be greatly appreciated.

Thanks.

morgan@resapphealth.com.au (JIRA)

unread,
Jul 4, 2019, 8:31:02 PM7/4/19
to jenkinsc...@googlegroups.com

I too would like to add my support behind this request.  Just like code should be readable, so should a UI.  I want my users to be able to glance at a blue ocean build & know what's happening without having to trawl though build logs.

morgan@resapphealth.com.au (JIRA)

unread,
Jul 4, 2019, 8:35:03 PM7/4/19
to jenkinsc...@googlegroups.com
Morgan Robertson edited a comment on Bug JENKINS-43820
I too would like to add my support behind this request.  Just like code should be readable, so should a UI.  I want my users to be able to glance at a blue ocean build & know what's happening without having to trawl though build logs. [~abayer] please consider reopening this issue.

jeremy@mathevet.net (JIRA)

unread,
Sep 25, 2019, 2:42:03 AM9/25/19
to jenkinsc...@googlegroups.com

Please reconsider!
There are some cases where this could be useful.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

larry_west@intuit.com (JIRA)

unread,
Sep 25, 2019, 1:49:02 PM9/25/19
to jenkinsc...@googlegroups.com

Andrew Bayer - a "design decision" that neither satisfies the customer nor addresses some inherent constraint is indistinguishable from a design flaw.

Please have someone else in your organization – who is not invested in this "design decision" – re-evaluate this.

Thanks!

larry_west@intuit.com (JIRA)

unread,
Sep 27, 2019, 2:04:09 PM9/27/19
to jenkinsc...@googlegroups.com
Larry West updated an issue
 
Jenkins / Bug JENKINS-43820
Change By: Larry West
Comment: [~abayer] - a "design decision" that neither satisfies the customer nor addresses some inherent constraint is indistinguishable from a design flaw.


Please have someone else in your organization – who is not invested in this "design decision" – re-evaluate this.

Thanks!

yotu.tuy@gmail.com (JIRA)

unread,
Oct 8, 2019, 7:59:02 AM10/8/19
to jenkinsc...@googlegroups.com
Karolina Arancibia Valuskova commented on Bug JENKINS-43820
 
Re: Stage name must be a string literal

This worked for me (Jenkins ver 2.190.1):
stage ("Deploy ${BRANCH_NAME}")

chris@chrishemp.com (JIRA)

unread,
Oct 18, 2019, 7:52:02 AM10/18/19
to jenkinsc...@googlegroups.com

Karolina Arancibia Valuskova is that with scripted pipeline or declarative syntax? I tried above inside declarative syntax (`pipeline {...}`) and above did not work.

dave.cashin@ca.ibm.com (JIRA)

unread,
Dec 11, 2019, 2:22:03 PM12/11/19
to jenkinsc...@googlegroups.com

Also asking this be reopened, this would be very helpful to have

ironchamp@gmail.com (JIRA)

unread,
Jan 29, 2020, 7:19:06 AM1/29/20
to jenkinsc...@googlegroups.com

For good coding practice, at least static variables ought to be considered.

I appreciate why stage names on any given pipeline ARE expected to be stable and concise. However,  please reconsider for fixed variables assuming a pre-pass of pre-declared env. variables would be useful since convenient for ease of maintenance across multiple stages, especially when cloning (or generating) similar pipelines.

pipeline {

environment

{   ENV = 'DEV'   PHASE = 'IT'   DELIVERY = "DELI"   BASE = "REGI" }

stages {

  stage('1.  Prepare ' + PHASE + ' DB')
    steps {
      script {

        println "Prepare " + PHASE + " to clean " + DELIVERY + " & " + BASE + " schemas within ${env.ENV} DB" 
        :

      }
    }
  }

  stage('2.  Generate ' + PHASE + 'Tests)
    steps {
      script {

        println "Generate " + PHASE + " for exec in both " + DELIVERY + " & " + BASE + "  ${env.ENV} environments" 
        :

      }
    }
  }

  // Exec parallel $PHASE tests
  :
}

}

ironchamp@gmail.com (JIRA)

unread,
Jan 29, 2020, 7:20:07 AM1/29/20
to jenkinsc...@googlegroups.com
Alan Champion edited a comment on Bug JENKINS-43820
For good coding practice, at least static variables ought to be considered.

I appreciate why stage names on any given pipeline ARE expected to be stable and concise. However,  please reconsider for *fixed* variables assuming a pre-pass of pre-declared env. variables would be useful since convenient for ease of maintenance across multiple stages, especially when if cloning (or generating) similar pipelines for different phases/environments .

pipeline {

environment
{

{
  ENV = 'DEV'
  PHASE = 'IT'
  DELIVERY = "DELI"
  BASE = "REGI"
}

stages {

  stage('1.  Prepare ' + PHASE + ' DB')
    steps {
      script {

        println "Prepare " + PHASE + " to clean " + DELIVERY + " & " + BASE + " schemas within ${env.ENV} DB" 
        :

      }
    }
  }

  stage('2.  Generate ' + PHASE + 'Tests)
    steps {
      script {

        println "Generate " + PHASE + " for exec in both " + DELIVERY + " & " + BASE + "  ${env.ENV} environments" 
        :

      }
    }
  }

  // Exec parallel $PHASE tests
  :
}

}

ironchamp@gmail.com (JIRA)

unread,
Jan 29, 2020, 7:21:04 AM1/29/20
to jenkinsc...@googlegroups.com
Alan Champion edited a comment on Bug JENKINS-43820
For good coding practice, at least static variables ought to be considered.

I appreciate why stage names on any given pipeline ARE expected to be stable and concise. However,  please reconsider for *fixed* variables assuming a pre-pass of pre-declared env. variables since convenient for ease of maintenance across multiple stages, especially if cloning (or generating) similar pipelines for different phases/environments.


pipeline {

environment

{   ENV = 'DEV'   PHASE = 'IT'   DELIVERY = "DELI"   BASE = "REGI" }

stages {

  stage('1.  Prepare ' + PHASE + ' DB')
    steps {
      script {

        println "Prepare " + PHASE + " to clean " + DELIVERY + " & " + BASE + " schemas within ${env.ENV} DB" 
        :

      }
    }
  }

  stage('2.  Generate ' + PHASE + 'Tests ' )
    steps {
      script {

        println "Generate " + PHASE + " for exec in both " + DELIVERY + " & " + BASE + "  ${env.ENV} environments" 
        :

      }
    }
  }

  // Exec parallel $PHASE tests
  :
}

}

ironchamp@gmail.com (JIRA)

unread,
Jan 29, 2020, 7:41:03 AM1/29/20
to jenkinsc...@googlegroups.com
Alan Champion edited a comment on Bug JENKINS-43820
For good coding practice, at least static variables ought to be considered , even in DSL .


I appreciate why stage names on any given pipeline ARE expected to be stable and concise. However,  please reconsider for *fixed* variables assuming a pre-pass of pre-declared env. variables since convenient for ease of maintenance across multiple stages, especially if cloning (or generating) similar pipelines for different phases/environments.

pipeline {

environment

{   ENV = 'DEV'   PHASE = 'IT'   DELIVERY = "DELI"   BASE = "REGI" }

stages {

  stage('1.  Prepare ' + PHASE + ' DB')
    steps {
      script {

        println "Prepare " + PHASE + " to clean " + DELIVERY + " & " + BASE + " schemas within ${env.ENV} DB" 
        :

      }
    }
  }

  stage('2.  Generate ' + PHASE + ' Tests')
    steps {
      script {

        println "Generate " + PHASE + " for exec in both " + DELIVERY + " & " + BASE + "  ${env.ENV} environments" 
        :

      }
    }
  }

  // Exec parallel $PHASE tests
  :
}

}

ironchamp@gmail.com (JIRA)

unread,
Jan 30, 2020, 7:46:04 AM1/30/20
to jenkinsc...@googlegroups.com
Alan Champion edited a comment on Bug JENKINS-43820
For good coding practice, at least static variables ought to be considered, even in DSL.

[~abayer] - I appreciate why stage names on any given pipeline ARE expected to be stable and concise . However,  please can you kindly reconsider for * fixed constant * variables assuming a pre-pass of pre-declared env. variables , since convenient for ease of maintenance across multiple stages, especially if after cloning (or generating) similar pipelines for different phases/environments.


pipeline {

environment

{   ENV = 'DEV'   PHASE = 'IT'   DELIVERY = "DELI"   BASE = "REGI" }

stages {

  stage('1.  Prepare ' + PHASE + ' DB')
    steps {
      script {

        println "Prepare " + PHASE + " to clean " + DELIVERY + " & " + BASE + " schemas within ${env.ENV} DB" 
        :

      }
    }
  }

  stage('2.  Generate ' + PHASE + ' Tests')
    steps {
      script {

        println "Generate " + PHASE + " for exec in both " + DELIVERY + " & " + BASE + "  ${env.ENV} environments" 
        :

      }
    }
  }

  // Exec parallel $PHASE tests
  :
}

}

Luke.Lussenden@gmail.com (JIRA)

unread,
Mar 19, 2020, 8:57:04 PM3/19/20
to jenkinsc...@googlegroups.com

I would also appreciate support for constants.

My use-case involves shared library code which makes post action decisions based on the failed stage name.

Re-defining the stage name in multiple places is brittle and someone could easily decide to change the display name causing code to silently fail when the stage name doesn't match what it's looking for.  Using a constant would help this problem.

 

Support for:

static final String BUILD = "Build Stage"

 For stage names would be most appreciated.

 

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

madhu.shesharam@gmail.com (JIRA)

unread,
Mar 28, 2020, 2:14:04 AM3/28/20
to jenkinsc...@googlegroups.com
madhu Shesharam updated an issue
 
Change By: madhu Shesharam
Attachment: image-2020-03-28-00-13-53-948.png

madhu.shesharam@gmail.com (JIRA)

unread,
Mar 28, 2020, 2:15:04 AM3/28/20
to jenkinsc...@googlegroups.com
madhu Shesharam updated an issue
Change By: madhu Shesharam
Attachment: image-2020-03-28-00-14-28-613.png

madhu.shesharam@gmail.com (JIRA)

unread,
Mar 28, 2020, 2:17:03 AM3/28/20
to jenkinsc...@googlegroups.com
madhu Shesharam commented on Bug JENKINS-43820
 
Re: Stage name must be a string literal

Jenkins DSL (declarative syntax)  Below should work for Dynamic State Names.

 

/** code placeholder

**/



def buildType
pipeline {  
  agent any
    parameters { 
       choice(name: 'BUILDTYPE', choices: ['ANDROID', 'IOS', 'LINUX', 'WINDOWS'], description: 'Pick Build Type')    
   }

  stages {       
      stage('Prepare') {     
            steps {                
              script { 
                    buildType = "${params.BUILDTYPE}"  
                    createBuilds(buildType)   // Dynamic Stage Name  
              }  
          }
        } 
     }
}


def createBuilds(thestage){ 
    stage(thestage) {    
    echo "$thestage"   
    if (thestage.contains("ANDROID"))
        {  echo "Build Specific to $thestage"           
         // Do execute based on ?
        } 
     }
}






 
 
 

 

brian.murrell@intel.com (JIRA)

unread,
Apr 21, 2020, 4:08:03 PM4/21/20
to jenkinsc...@googlegroups.com
Brian J Murrell updated an issue
 
Change By: Brian J Murrell
Attachment: screenshot-matrix.png

brian.murrell@intel.com (JIRA)

unread,
Apr 21, 2020, 4:09:03 PM4/21/20
to jenkinsc...@googlegroups.com
Brian J Murrell commented on Bug JENKINS-43820
 
Re: Stage name must be a string literal

This gets really, super ugly in the context of matrix. Surely you can see how not being able to substitute a variable into the stage name makes this a much less-than-useful representation of the job:

I have no idea what any of those stages are without hovering over the "Matrix" text for each combination.

kahmeal@gmail.com (JIRA)

unread,
Apr 23, 2020, 5:34:04 PM4/23/20
to jenkinsc...@googlegroups.com

Just chiming in to voice my support for Brian J Murrell as I ran into the same limitation with matrix stages myself and do not see the proposed workaround as a viable one in these scenarios. Responding with "conscious design decision" and no other explanation is a cop out and, given the very valid nature of the responses here, I would challenge you to defend the statement Andrew Bayer.

Reply all
Reply to author
Forward
0 new messages