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

Environment variables assigned to existing script variables

      This pipeline script appears to be attempting to assign the value for what should be a User variable in the script environment to an existing groovy script variable, resulting in this error: you tried to assign a value to the class 'hudson.model.User' @ line 11, column 5.

      Perhaps this is expected behavior? I would assume these variables should be in the context of env. Maybe this is a special case?

      pipeline {
        agent any
        stages {
          stage('Build') {
            steps {
              sh('mvn package')
            }
          }
        }
        environment {
          User = 'asdf'
        }
      }
      

          [JENKINS-41257] Environment variables assigned to existing script variables

          Andrew Bayer added a comment -

          Ah, so the problem is that User is, well, hudson.model.User. I'll see if I can work around that...

          Andrew Bayer added a comment - Ah, so the problem is that User is, well, hudson.model.User . I'll see if I can work around that...

          Andrew Bayer added a comment -

          And I can't! That'll fail before it ever gets to anything I control. Grr.

          Andrew Bayer added a comment - And I can't! That'll fail before it ever gets to anything I control. Grr.

          Andrew Bayer added a comment -

          Yeah, digging further, I can't catch this without some really loopy hacks. The checking for a valid identifier happens in the SEMANTIC_ANALYSIS compilation phase, as does our AST parsing (as of JENKINS-42753 - previously, it was in the next phase, CANONICALIZATION), but the identifier check happens before our AST parsing. So this error is gonna show up before I can report on it in a better way. Sigh.

          Andrew Bayer added a comment - Yeah, digging further, I can't catch this without some really loopy hacks. The checking for a valid identifier happens in the SEMANTIC_ANALYSIS compilation phase, as does our AST parsing (as of JENKINS-42753 - previously, it was in the next phase, CANONICALIZATION ), but the identifier check happens before our AST parsing. So this error is gonna show up before I can report on it in a better way. Sigh.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            kzantow Keith Zantow
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: