Here is my caller workflow
:
name: Dev-Release
on:
workflow_dispatch:
jobs:
BUILD:
uses: mybank/DevOps/.github/workflows/buildmaven.yml@mybranch
RELEASE:
needs: [BUILD]
runs-on: "self-hosted1755"
steps:
- name: Release to DEV
run: |
Write-Host "NEWJAVAPATH - ${{ needs.BUILD.outputs.newjavapath }} i.e $env:JAVA_HOME"
Here is my called Reusable Workflow
:
on:
workflow_call:
outputs:
newjavahome:
value: ${{ jobs.BUILD_APP.outputs.newjavahome }}
jobs:
BUILD_APP:
runs-on: "self-hosted1755"
outputs:
newjavahome: "${{ steps.printnewpath.outputs.newjavahome }}"
steps:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Print JAVA Home
id: printnewpath
run: |
Write-Host "NEW JAVA HOME is $env:JAVA_HOME"
echo "newjavahome=$env:JAVA_HOME" >> "$env:GITHUB_OUTPUT"
I'm able to print NEW JAVA HOME is D:\what\ever\path\JAVA\x86
during the execution of the reusable workflow.
However, i m in need to carry this value and print it in caller workflow job named RELEASE:
Can you please suggest what am i missing?
It looks like you're trying to pass the JAVA_HOME value from a reusable workflow back to the caller workflow and then use it in a subsequent job. The main issue seems to be with how
the output is being set and accessed.
Reusable Workflow:
• Ensure the output newjavahome is correctly set using GITHUB_OUTPUT .
• The output is referenced as ${{ steps.printnewpath.outputs.newjavahome }}
Caller Workflow:
• Reference the output from the reusable workflow using ${{ needs.BUILD.outputs.newjavahome }}