How can I pass my branch name suffix as input to Post Jira Comment step

We have a convention that branch name should start with JIRA ticket number

so if Jira ticket is :
so branch name will start with PP-4045-branch-name

Jira issue key is a required input for this step. How can I enter this value dynamically in my case?

Hi @abdul-hannan!

You can use the “Script” step to split the Jira ticket number:

    - git-clone: {}
    - script@1.1.5:
        - content: |-
            #!/usr/bin/env bash
            set -e
            set -x

            #Split the branch name by '-' and get the issue key
            issue_key_prefix="$(cut -f1 -d"-" <<<"$BITRISE_GIT_BRANCH")"
            issue_key_number="$(cut -f2 -d"-" <<<"$BITRISE_GIT_BRANCH")"

            echo "${issue_key}"

            #Export the issue_key via envman
            envman add --key ISSUE_KEY --value "${issue_key}"
    - post-jira-comment-with-build-details@1.0.0:
        - api_token: "$BITRISE_JIRA_API_TOKEN"
        - issue_keys: "$ISSUE_KEY"
        - base_url: "$BITRISE_JIRA_BASE_URL"
        - user_name: "$BITRISE_JIRA_USER_NAME"
1 Like

how to use same on the web dashboard of bitrise

Hi @HarshalBhavsar!

You can do this on the web, by adding the Script step to your workflow!

Thanks @BirmacherAkos, your answer gave me the idea, but I used a different script instead to achieve the same

1 Like

@bitce I did figured out after posting here. Thanks for the script also. It’s working nicely for me

1 Like

@abdul-hannan You can share your script also so people have more options

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.