Skip to content

Commit

Permalink
ci: populate jira branch custom field from pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaian committed Dec 12, 2024
1 parent db380ef commit 842b736
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,35 @@ pipeline {
SYMFONY_PHPUNIT_DIR = "/opt/phpunit/"
SYMFONY_PHPUNIT_VERSION = "9.5.3"
DOCKER_TAG = getDockerTag()
BRANCH_NAME = getBranchName()
BASE_BRANCH = getBaseBranch()
JIRA_TICKET = getJiraTicket()
}

stages {
stage('Pull Request') {
agent any
when {
expression {
env.BRANCH_NAME.startsWith("PROVIDER-")
}
}
steps {
// Update Jira Ticket Custom fields
script {
// customfield_10126 - Merge Request
// customfield_10159 - Branch
def fields = [
fields: [
customfield_10126: env.JOB_BASE_NAME,
customfield_10159: env.CHANGE_BRANCH,
]
]
jiraEditIssue site: 'irontec.atlassian.net', idOrKey: env.JIRA_TICKET, issue: fields
}
}
}

// --------------------------------------------------------------------
// Image stage
// --------------------------------------------------------------------
Expand Down Expand Up @@ -651,11 +675,6 @@ pipeline {
println "No functional reviewer assigned."
}

// Link issue Pull Request field with current branch
// customfield_10126 - Pull Request
def fields = [fields: [customfield_10126: env.JOB_BASE_NAME]]
jiraEditIssue site: 'irontec.atlassian.net', idOrKey: env.JIRA_TICKET, issue: fields

// Validated - 10325
def status = issue.data.fields.status
println "Issue Status: ${status.name} (${status.id})"
Expand Down Expand Up @@ -725,6 +744,10 @@ boolean hasCommitTag(String module) {
) == 0
}

void getBranchName() {
return env.CHANGE_BRANCH ?: env.GIT_BRANCH
}

void getBaseBranch() {
return env.CHANGE_TARGET ?: env.GIT_BRANCH
}
Expand Down

0 comments on commit 842b736

Please sign in to comment.