Skip to content

Commit 842b736

Browse files
committed
ci: populate jira branch custom field from pipeline
1 parent db380ef commit 842b736

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

Jenkinsfile

+28-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,35 @@ pipeline {
2626
SYMFONY_PHPUNIT_DIR = "/opt/phpunit/"
2727
SYMFONY_PHPUNIT_VERSION = "9.5.3"
2828
DOCKER_TAG = getDockerTag()
29+
BRANCH_NAME = getBranchName()
2930
BASE_BRANCH = getBaseBranch()
3031
JIRA_TICKET = getJiraTicket()
3132
}
3233

3334
stages {
35+
stage('Pull Request') {
36+
agent any
37+
when {
38+
expression {
39+
env.BRANCH_NAME.startsWith("PROVIDER-")
40+
}
41+
}
42+
steps {
43+
// Update Jira Ticket Custom fields
44+
script {
45+
// customfield_10126 - Merge Request
46+
// customfield_10159 - Branch
47+
def fields = [
48+
fields: [
49+
customfield_10126: env.JOB_BASE_NAME,
50+
customfield_10159: env.CHANGE_BRANCH,
51+
]
52+
]
53+
jiraEditIssue site: 'irontec.atlassian.net', idOrKey: env.JIRA_TICKET, issue: fields
54+
}
55+
}
56+
}
57+
3458
// --------------------------------------------------------------------
3559
// Image stage
3660
// --------------------------------------------------------------------
@@ -651,11 +675,6 @@ pipeline {
651675
println "No functional reviewer assigned."
652676
}
653677

654-
// Link issue Pull Request field with current branch
655-
// customfield_10126 - Pull Request
656-
def fields = [fields: [customfield_10126: env.JOB_BASE_NAME]]
657-
jiraEditIssue site: 'irontec.atlassian.net', idOrKey: env.JIRA_TICKET, issue: fields
658-
659678
// Validated - 10325
660679
def status = issue.data.fields.status
661680
println "Issue Status: ${status.name} (${status.id})"
@@ -725,6 +744,10 @@ boolean hasCommitTag(String module) {
725744
) == 0
726745
}
727746

747+
void getBranchName() {
748+
return env.CHANGE_BRANCH ?: env.GIT_BRANCH
749+
}
750+
728751
void getBaseBranch() {
729752
return env.CHANGE_TARGET ?: env.GIT_BRANCH
730753
}

0 commit comments

Comments
 (0)