Skip to content

fix: Publish stage skipped due to broken stageDependencies output variable in 1ES template#4094

Merged
Saadnajmi merged 1 commit intomicrosoft:mainfrom
Saadnajmi:fix-publish-pipeline-condition
Apr 24, 2026
Merged

fix: Publish stage skipped due to broken stageDependencies output variable in 1ES template#4094
Saadnajmi merged 1 commit intomicrosoft:mainfrom
Saadnajmi:fix-publish-pipeline-condition

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

Follow-up to #4093

PR #4093 fixed the not(${{ parameters.skipNpmPublish }}) compile-time/runtime boolean mismatch, but the Publish stage is still being skipped.

Root Cause

The remaining issue is the stageDependencies output variable reference:

eq(stageDependencies.Build.BuildAndPack.outputs['check.hasTarballs'], 'true')

Under 1ES Pipeline Templates, templateContext.outputs restructures the job internally. This breaks the stageDependencies reference path — the output variable resolves to empty, so eq('', 'true')false, and the stage is always skipped.

Fix

  1. Remove the cross-stage output variable dependency from the stage condition. The simplified condition is now:

    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne('${{ parameters.skipNpmPublish }}', 'true'))
  2. Move the tarball check into the Publish job — after downloading the artifact, verify tarballs exist and fail early with a clear error if they don't:

    - script: |
        echo "Downloaded tarballs:"
        ls -la $(System.DefaultWorkingDirectory)/_packed/
        if ! ls $(System.DefaultWorkingDirectory)/_packed/*.tgz > /dev/null 2>&1; then
          echo "##vso[task.logissue type=error]No tarballs found in _packed/"
          exit 1
        fi
      displayName: 'Verify downloaded tarballs'

This is more robust than relying on cross-stage output variables through the 1ES template layer.

@Saadnajmi Saadnajmi marked this pull request as draft April 24, 2026 21:42
@Saadnajmi Saadnajmi force-pushed the fix-publish-pipeline-condition branch 3 times, most recently from dd60380 to 0ae2bfd Compare April 24, 2026 21:55
@Saadnajmi Saadnajmi marked this pull request as ready for review April 24, 2026 21:57
Two issues in the Publish stage condition:

1. not(${{ parameters.skipNpmPublish }}) mixes compile-time template
   expansion with runtime expression evaluation. The YAML boolean expands
   to 'False'/'True' (capital), which are non-empty strings (always truthy
   in runtime), so not() always returns false. Fix: use ne() string
   comparison instead.

2. stageDependencies.Build.BuildAndPack.outputs['check.hasTarballs'] does
   not resolve correctly under 1ES Pipeline Templates, because
   templateContext.outputs restructures the job and breaks the output
   variable reference path. Fix: remove the cross-stage variable dependency
   and verify tarballs exist inside the Publish job after downloading the
   artifact.
@Saadnajmi Saadnajmi force-pushed the fix-publish-pipeline-condition branch from 0ae2bfd to 7df9c90 Compare April 24, 2026 22:09
@Saadnajmi Saadnajmi enabled auto-merge (squash) April 24, 2026 22:10
@Saadnajmi Saadnajmi merged commit 828bdef into microsoft:main Apr 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants