Saichovsky
01/19/2024, 12:19 PMjob1) and gives an output that looks like this:
{
"A": "123",
"B": "234",
"C": "345"
}
I would like to have another job, say job2 that runs after job1 and consumes the output from job1 for use in a matrix. I want the matrix for job 2 to look like this:
job2:
needs: ["job1"]
strategy:
matrix:
env:
[
{ environment: production, item: [ "A", "B", "C" ] }, # Note that A, B and C are the keys from job1's output JSON
{ environment: development, item: [ "A", "B", "C" ] }} }
]
I shall be needing `job1`'s output as a complete JSON in job2 as I shall be using jq to retrieve the values, for each key in matrix.env.item
What’s the best way to go about this?Gabriela Campana (Cloud Posse)
01/19/2024, 8:27 PMSaichovsky
01/22/2024, 1:23 PMjob1 using jq -c 'keys' and then sends the output (an array of the keys: A, B & C) to job2Igor Rodionov
01/26/2024, 1:44 PMIgor Rodionov
01/26/2024, 1:48 PMjob2:
needs: ["job1"]
strategy:
matrix:
include:
- environment: production
item: ${{ needs.job1.outputs.items }}
- environment: development
item: ${{ needs.job1.outputs.items }}Igor Rodionov
01/26/2024, 1:48 PMIgor Rodionov
01/26/2024, 1:50 PMjob2:
needs: ["job1"]
strategy:
matrix:
environment: ["production", development"]
items: [${{ toJSON(needs.job1.outputs.items) }}]Igor Rodionov
01/26/2024, 1:50 PMIgor Rodionov
01/26/2024, 1:50 PMIgor Rodionov
01/26/2024, 1:50 PMSaichovsky
01/26/2024, 1:52 PMfromJSON function. But thanks for the two examples 🤝🏽Igor Rodionov
01/26/2024, 1:54 PMIgor Rodionov
01/26/2024, 1:54 PMIgor Rodionov
01/26/2024, 1:54 PMIgor Rodionov
01/26/2024, 1:55 PMIgor Rodionov
01/26/2024, 1:55 PMIgor Rodionov
01/26/2024, 1:56 PMIgor Rodionov
01/26/2024, 1:56 PMIgor Rodionov
01/26/2024, 1:56 PM