0
How to prevent changes without Jira ID
Some times we can push changes without Jira ID ,so I want to prevent those kind of changes Suppose my project like abc, def , ghi and Jira ID like 1234-abc , 2525-def and 36789-ghi Now how to write script using python for below tasks 1) create Jira ID provided is valid or not 2) check type of Jira for abc or def , it should be change request only 3) Check status of Jira , it should be in ""Accepted or Assigned " Me also started writing script now anyone please help me out .
3 Respuestas
0
Hi all any suggestions , could you please let me know .
0
#!/usr/bin/env python3
#This pre push hook will stop pushing the changes if the branch name doesn't have jira ID
import sys, os, re, subprocess
# patterns to serach in the branch name
list_patterns = ["0000061142-.","0000005040-.*","MC_ASE_ENV-.*","CIBR0001-.*","0000065087-.","0000061475-.*"]
# get the current branch name
get_status = 'git rev-parse --abbrev-ref HEAD'
ps = subprocess.Popen(get_status,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE, stdin=subprocess.PIPE)
currentbranch = ps.communicate()[0].decode("utf-8")
#search of jira ID Eg: abcd1234 in the current branch name
for branch_pattern in list_patterns:
if re.search(branch_pattern , currentbranch):
print("your code is pushed successfully")
break
else:
#prevent push changes if the jiraid is not present branch name
print("\t Refused to push because jira id is missing in brannch name %s" %(str(currentbranch)))
sys.exit(1)
0
This is the code we developed
This code need to be satisfied below conditions
1) Provided jira id is valid or not
2) provided jira id is matches to particular project or not like abc or def like that
Next condition if above two satisfied
1)If jira pattern satisfied it should be change request
2) The provided jira id is in which status
Anyone suggest me how to write the code for above conditions any useful restapi also