GabrielBB
GabrielBB

Reputation: 2689

Get current job name in Github Actions workflow

I want to reference the running job name in one of its steps. These are the options Github gives us: https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#job-context. The closer one I see is "job.container.id". Would that give me the name I set to the job? It doesn't sound like it. Unfortunately, I can't no longer test this since I exceeded the limit of free Github Actions usage

Upvotes: 28

Views: 19311

Answers (2)

Max Murphy
Max Murphy

Reputation: 1973

Update 2023: The current method for getting the current job name:

      - name: Get job name
        run: |
          # Both work:
          echo "Job name is $GITHUB_JOB"
          echo "How about ${{ github.jobs[github.job].name }}"

Upvotes: -2

Chandan Gupta
Chandan Gupta

Reputation: 496

github.job might get you the job name

Link to documentation: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

enter image description here

Upvotes: 15

Related Questions