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

Env variable expansion in tasks of builds without a workspace is broken since TokenUtils 2.0

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins 2.218
      Token Macro Plugin 2.10
      Delivery Pipeline Plugin 1.4.0
      Amazon Elastic Container Service (ECS) / Fargate plugin 1.25

      We are using delivery pipeline views, and we moved many of our build jobs to "Cloud" nodes ( ecs instances ) for which the workspace is not persisted after the build is finished.

       

       

      As a result, token macro expansion is working fine during the build ( because the workspace exists ), but once the build is finished our pipeline displays un-expanded variables such as ${GIT_BRANCH} etc.

       

      The cause is that the Token Macro plugin requires a workspace for calls to TokenUtil.expandAll() since version 2.0 .

       

      Note that #JENKINS-40763 did a workaround for the issue: it just catches the exception raised by TokenUtils and displays the variables without expansion ( which is arguably much better than not showing a pipeline at all ).

       

      As a workaround I did a fork which:

       - updates the dependencies to TokenUtils 2.0  ( required for access to new expandAll methods )

       - checks if the build has a valid workspace

       - if not, create a null "VirtualChannel" FilePath and changes the call to ExpandAll

       

      Maybe there is a better solution. I am not a java developper but the fix might be useful to others.

      https://github.com/openwengo/delivery-pipeline-plugin/commit/39ed9ca0f5349423d0e5e5ab86692854c2d33af1

       

       

       

            patbos Patrik Boström
            owengo Olivier Schiavo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: