Skip to content

Fix: repair Maven merge SNAPSHOT publishing - #896

Merged
ModeSevenIndustrialSolutions merged 1 commit into
lfit:mainfrom
askb:fix/compose-maven-merge-snapshot
Sep 1, 2026
Merged

ModeSevenIndustrialSolutions merged 1 commit into
lfit:mainfrom
askb:fix/compose-maven-merge-snapshot

Conversation

@askb

@askb askb commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

compose-maven-merge could not publish. Four independent defects:

  1. Boolean gates never matched. PUSH_NEXUS, PUSH_ARTIFACTORY,
    PUSH_CENTRAL and SIGUL_SIGN were compared with == 'true'. A typed
    workflow_call boolean arrives as a real boolean, and comparing a
    boolean to a string casts the string to a number, giving NaN, so
    the gate was always false. Verified on a runner: with FLAG passed
    as true, a job gated on inputs.FLAG == 'true' is skipped while one
    gated on inputs.FLAG runs. Every publish job, and artifact signing,
    was dead code.

  2. ARTIFACT_DIR defaulted to the literal string ${GITHUB_WORKSPACE}/m2repo.
    GitHub only expands ${{ }}, so upload-artifact, download-artifact and
    sigul received a path containing an unexpanded shell variable. Now
    defaults to the workspace-relative m2repo; absolute overrides still
    work.

  3. repository_name read ${{ env.NEXUS_REPO }}, which is never defined
    in this workflow, so it resolved empty. Use vars.NEXUS_REPO.

  4. SNAPSHOT buildNumber restarted at 1 on every run. maven-deploy-plugin
    derives the next buildNumber from the maven-metadata.xml already in
    the local repository; a clean runner has none, so each publish
    clobbered the SNAPSHOT history rather than appending to it. Pre-fetch
    the published metadata before the build, and publish with
    repository_format maven2_upload scoped to the project group path so
    the uploaded tree carries Maven coordinates.

The pre-fetch pulls every maven-metadata.xml already published for the
group, most of which a given build never touches. Uploading those back
unchanged would revert any sibling artifact published while the build
was running, so byte-identical metadata and its checksums are dropped
before publishing. This mirrors global-jjb, where maven-fetch-metadata.sh
and maven-deploy.sh have always been a pair; only the fetch half had
been carried over.

The group path is read from the project's own groupId, falling back to
the parent's per Maven's inheritance rule, matching the xmlstarlet query
in global-jjb. Grepping the first returns the parent instead,
which silently pre-fetches the wrong project's metadata.

Also adds an ENV_VARS input so callers can expose repository variables
to the build, matching compose-maven-verify.

Verified against opendaylight/infrautils, which runs this logic inline
today and now publishes an incrementing buildNumber.

Signed-off-by: Anil Belur abelur@linuxfoundation.org

@github-actions github-actions Bot added the bug Something isn't working label Sep 1, 2026
@askb
askb force-pushed the fix/compose-maven-merge-snapshot branch from 10dc3e5 to 4332d8e Compare September 1, 2026 13:10
compose-maven-merge could not publish. Four independent defects:

1. Boolean gates never matched. PUSH_NEXUS, PUSH_ARTIFACTORY,
   PUSH_CENTRAL and SIGUL_SIGN were compared with == 'true'. A typed
   workflow_call boolean arrives as a real boolean, and comparing a
   boolean to a string casts the string to a number, giving NaN, so
   the gate was always false. Verified on a runner: with FLAG passed
   as true, a job gated on inputs.FLAG == 'true' is skipped while one
   gated on inputs.FLAG runs. Every publish job, and artifact signing,
   was dead code.

2. ARTIFACT_DIR defaulted to the literal string ${GITHUB_WORKSPACE}/m2repo.
   GitHub only expands ${{ }}, so upload-artifact, download-artifact and
   sigul received a path containing an unexpanded shell variable. Now
   defaults to the workspace-relative m2repo; absolute overrides still
   work.

3. repository_name read ${{ env.NEXUS_REPO }}, which is never defined
   in this workflow, so it resolved empty. Use vars.NEXUS_REPO.

4. SNAPSHOT buildNumber restarted at 1 on every run. maven-deploy-plugin
   derives the next buildNumber from the maven-metadata.xml already in
   the local repository; a clean runner has none, so each publish
   clobbered the SNAPSHOT history rather than appending to it. Pre-fetch
   the published metadata before the build, and publish with
   repository_format maven2_upload scoped to the project group path so
   the uploaded tree carries Maven coordinates.

The pre-fetch pulls every maven-metadata.xml already published for the
group, most of which a given build never touches. Uploading those back
unchanged would revert any sibling artifact published while the build
was running, so byte-identical metadata and its checksums are dropped
before publishing. This mirrors global-jjb, where maven-fetch-metadata.sh
and maven-deploy.sh have always been a pair; only the fetch half had
been carried over.

The group path is read from the project's own groupId, falling back to
the parent's per Maven's inheritance rule, matching the xmlstarlet query
in global-jjb. Grepping the first <groupId> returns the parent instead,
which silently pre-fetches the wrong project's metadata.

Also adds an ENV_VARS input so callers can expose repository variables
to the build, matching compose-maven-verify.

Verified against opendaylight/infrautils, which runs this logic inline
today and now publishes an incrementing buildNumber.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
@askb
askb force-pushed the fix/compose-maven-merge-snapshot branch from 4332d8e to 91f287a Compare September 1, 2026 13:10
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 94ae936 into lfit:main Sep 1, 2026
12 checks passed
odl-github pushed a commit to opendaylight/infrautils that referenced this pull request Sep 1, 2026
Replace the inline maven-merge and publish-nexus jobs with a call to
lfit/releng-reusable-workflows compose-maven-merge, keeping prepare
and vote local since the reusable workflow has no Gerrit integration.

The SNAPSHOT metadata pre-fetch and the maven2_upload publish that
were developed here have been upstreamed, so this repo no longer
carries a private copy. 115 lines of workflow become 23.

secrets: inherit is required because compose-maven-merge reads
secrets.NEXUS_USERNAME and secrets.NEXUS_PASSWORD without declaring
a secrets block of its own.

Depends on lfit/releng-reusable-workflows#896, which is merged. That
PR added the ENV_VARS input, repaired the publish gates, and ported
the unmodified-metadata pruning from global-jjb.

Note that a workflow change takes effect one merge late: Gerrit
dispatches via workflow_dispatch on refs/heads/master, and GitHub
resolves the workflow file before replication completes. Verify with
a manual dispatch rather than from the run this change triggers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change-Id: If601f8579f9e45138474104da856f80d814ea018
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants