Skip to content

Re-structure env-variables to correct format for JSON #26854

Answered by airtower-luna
Ashta0 asked this question in Actions
Discussion options

You must be logged in to vote

When you use ${{ env.Tickets }} what happens is a simple string substitution, the literal value of the Tickets environment variable is placed at the location. If you want it contain a JSON structure you’ll have to create that yourself. Note that to get a valid JSON array of issues your json field should look like this:

{"issues": ["JIRAKey-1", "JIRAKey-2", "JIRAKey-3"]}

I like Python, so I’d use something like this:

- name: Create ticket list
  shell: python3 {0}
  run: |
    import json
    import os
    print(f'::set-env name=TICKET_LIST::{json.dumps(os.environ["Tickets"].split())}')

Well, I’d probably integrate that with parsing the git log output, but I think the idea is visible.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@subscriptionm

This comment was marked as disruptive content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants