成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Jira自動化實踐:基于Jenkins實現需求與代碼基線關聯

運維 系統運維 自動化
JIRA是Atlassian公司出品的項目與事務跟蹤工具,被廣泛應用于缺陷跟蹤、客戶服務、需求收集、流程審批、任務跟蹤、項目跟蹤和敏捷管理等工作領域。

[[434986]]

一. Jira簡介

中文官網:https://www.atlassian.com/zh/software/jira

1.1 Jira可以做什么?

規劃

創建項目,用戶需求和事務、規劃 Sprint 并跨團隊分配開發任務。

跟蹤

全面了解項目進度情況,安排整個團隊工作的優先級排序并進行討論。

二. 安裝部署

2.1 數據中心版本

https://www.atlassian.com/zh/software/jira/pricing?tab=data-center 試用 

選擇歷史版本下載:

下載最新的LTS 長期支持版本:

選擇部署的環境:

開始下載Jira Software Server安裝程序:

2.2 安裝部署

  1. scp atlassian-jira-software-8.20.1-x64.bin  root@192.168.1.200:/opt/ 
  2.  
  3. ## 添加權限 
  4. [root@zeyang-nuc-service opt]# chmod +x atlassian-jira-software-8.20.1-x64.bin 
  5.  
  6.  
  7. ## 運行安裝程序 
  8. [root@zeyang-nuc-service opt]# ./atlassian-jira-software-8.20.1-x64.bin 
  9. Unpacking JRE ... 
  10. Starting Installer ... 
  11.  
  12. This will install Jira Software 8.20.1 on your computer. 
  13. OK [o, Enter], Cancel [c]      ## 回車 
  14.  
  15. Click Next to continueor Cancel to exit Setup. 
  16.  
  17. Choose the appropriate installation or upgrade option
  18. Please choose one of the following: 
  19. Express Install (use default settings) [1], Custom Install (recommended for advanced users) [2, Enter], Upgrade an existing Jira installation [3] 
  20.  
  21. ## 此處選擇自定義安裝,  輸入回車 
  22.  
  23. Select the folder where you would like Jira Software to be installed. 
  24. Where should Jira Software be installed? 
  25. [/opt/atlassian/jira] 
  26.  
  27. ## 選擇安裝目錄 
  28.  
  29.  
  30. Default location for Jira Software data 
  31. [/var/atlassian/application-data/jira] 
  32.  
  33. ## 選擇數據目錄 
  34.  
  35. Configure which ports Jira Software will use. 
  36. Jira requires two TCP ports that are not being used by any other 
  37. applications on this machine. The HTTP port is where you will access Jira 
  38. through your browser. The Control port is used to startup and shutdown Jira. 
  39. Use default ports (HTTP: 8080, Control: 8005) - Recommended [1, Enter], Set custom value for HTTP and Control ports [2] 
  40. 2   ## 輸入2  自定義服務端口 
  41. HTTP Port Number 
  42. [8071] 
  43. 8801 
  44. Control Port Number 
  45. [8077] 
  46. 8802 
  47.  
  48. ## 安裝服務 
  49. Jira can be run in the background. 
  50. You may choose to run Jira as a service, which means it will start 
  51. automatically whenever the computer restarts. 
  52. Install Jira as Service? 
  53. Yes [y, Enter], No [n] 
  54.  
  55.  
  56. Details on where Jira Software will be installed and the settings that will be used. 
  57. Installation Directory: /opt/atlassian/jira 
  58. Home Directory: /var/atlassian/application-data/jira 
  59. HTTP Port: 8801 
  60. RMI Port: 8802 
  61. Install as service: Yes 
  62. Install [i, Enter], Exit [e] 
  63.  
  64.  
  65. Extracting files ... 
  66.  
  67.  
  68. ## 啟動服務 
  69. Please wait a few moments while Jira Software is configured. 
  70.  
  71. Installation of Jira Software 8.20.1 is complete 
  72. Start Jira Software 8.20.1 now? 
  73. Yes [y, Enter], No [n] 
  74.  
  75. Please wait a few moments while Jira Software starts up. 
  76. Launching Jira Software ... 
  77.  
  78.  
  79.  
  80. Installation of Jira Software 8.20.1 is complete 
  81. Your installation of Jira Software 8.20.1 is now ready and can be accessed 
  82. via your browser. 
  83. Jira Software 8.20.1 can be accessed at http://localhost:8801 
  84. Finishing installation ... 

訪問:http://serverip:8801

2.3 初始化配置

獲取授權碼:

注冊賬號登錄:生成授權碼,激活實例;

三. Jira使用實踐

3.1 創建一個項目

注意:一個Jira 項目對應一個GitLab項目組;

3.2 為項目添加模塊

注意:一個Jira模塊對應一個GitLab項目;

3.3 配置WebHook系統, 網絡鉤子(webhook)

3.4 需求/任務管理

創建需求

這里在Jira上面把這個需求logging-error, 類型為故事 關聯到devops03-devops-service模塊;

3.5 發布Release

課程中把 發布對應為GitLab項目代碼庫中的版本分支;

issue關聯發布:可以想象成GitLab特性分支合并到版本分支;

四. Jira自動化實踐

工作流

工具鏈集成

4.1 需求與代碼關聯

1. 創建Jenkins作業并配置webhook

webhookData:這個變量存放的是Jira 傳遞的數據。

2. 為Jira配置一個系統級別的webhook

選項解釋:

  • 指定Jenkins的webhook觸發器地址;
  • 通過JQL指定,允許devops03這個項目進行觸發;
  • 勾選動作,觸發事件;(我在jira做了什么操作之后能夠觸發)

3. Jenkins流水線配置

解析Jira傳遞過來的數據;

  1. webhookData = readJSON text: "${webhookData}" 
  2.  
  3.  
  4. // Jira事件 
  5. jiraEvent = webhookData.webhookEvent 
  6. jiraProjectName = webhookData.issue.fields.project.name 
  7.  
  8. // 獲取gitlab參數 
  9. gitlabProjects = [] 
  10. gitlabBranchName = webhookData.issue.key 
  11. gitlabGroupName = jiraProjectName 
  12.  
  13. for (i in webhookData.issue.fields.components){ 
  14.     gitlabProjects.add(i["name"]) 
  15.  
  16. currentBuild.description = "Trigger by ${jiraEvent} \n project: ${gitlabProjects} \n branch: ${gitlabBranchName}" 

封裝GitLab API接口

https://docs.gitlab.com/ee/api/branches.html#create-repository-branch

  1. // 創建分支 
  2. def CreateBranch(projectId, newBranchName, sourceBranchName){ 
  3.     try { 
  4.         apiUrl = "projects/${projectId}/repository/branches?branch=${newBranchName}&ref=${sourceBranchName}" 
  5.         response = HttpReq('POST', apiUrl, ""
  6.     } 
  7.     catch(Exception e) { 
  8.         println(e) 
  9.          
  10.     } 
  11.  
  12. // 獲取所有項目的id 
  13. def GetProjectsId(gitlabGroupName, gitlabProjects){ 
  14.     gitlabProjectIds = [] 
  15.     for (project in gitlabProjects){ 
  16.         id = GetProjectId(gitlabGroupName, project) 
  17.         println(id) 
  18.         if (id != 0){ 
  19.             gitlabProjectIds.add(id) 
  20.         } 
  21.     } 
  22.     return gitlabProjectIds 
  23.  
  24. // 根據項目名稱獲取項目id 
  25. def GetProjectId(groupName, projectName){ 
  26.     apiUrl = "projects?search=${projectName}" 
  27.     response = HttpReq('GET', apiUrl, ""
  28.     response = readJSON text: response.content - "\n" 
  29.  
  30.     if (response.size() > 1){ 
  31.         for (i in response){ 
  32.             println(i["path_with_namespace"]) 
  33.             println(groupName + projectName) 
  34.             if (i["path_with_namespace"] == "${groupName}/${projectName}"){ 
  35.                 println(i["id"]) 
  36.                 return i["id"
  37.             } 
  38.         } 
  39.     } else { 
  40.         return response[0]["id"
  41.     } 
  42.  
  43.  
  44. // 封裝HTTP 
  45. def HttpReq(reqType, reqUrl,reqBody ){ 
  46.     def gitServer = "http://192.168.1.200/api/v4" 
  47.     withCredentials([string(credentialsId: '058b7907-ebe2-4d14-9b91-1ac72e071c59', variable: 'GITLABTOKEN')]) { 
  48.         response = httpRequest acceptType: 'APPLICATION_JSON_UTF8',  
  49.                           consoleLogResponseBody: true,  
  50.                           contentType: 'APPLICATION_JSON_UTF8',  
  51.                           customHeaders: [[maskValue: falsename'PRIVATE-TOKEN', value: "${GITLABTOKEN}"]],  
  52.                           httpMode: "${reqType}",  
  53.                           url: "${gitServer}/${reqUrl}",  
  54.                           wrapAsMultipart: false
  55.                           requestBody: "${reqBody}" 
  56.  
  57.     } 
  58.     return response 

Pipeline主程序

  1. pipeline { 
  2.     agent { label "build" } 
  3.  
  4.     stages{ 
  5.         stage("Process"){ 
  6.             steps{ 
  7.                 script{ 
  8.                     println(gitlabProjects) 
  9.                     println(gitlabBranchName) 
  10.                     projectIds = GetProjectsId(gitlabGroupName, gitlabProjects) 
  11.                     switch(jiraEvent) { 
  12.                         case "jira:issue_created"
  13.                             println(projectIds) 
  14.                             for (id in projectIds){ 
  15.                                 CreateBranch(id, gitlabBranchName, "master"
  16.                             } 
  17.                             break 
  18.                         default
  19.                             println("error..."
  20.                             break 
  21.                     } 
  22.                 } 
  23.             } 
  24.         } 
  25.     } 

4. 效果驗證

在Jira里面創建一個模塊和issue, 關聯項目;

Jenkins 流水線運行;

驗證Gitlab中多了分支;

 

責任編輯:姜華 來源: DevOps云學堂
相關推薦

2021-04-13 06:15:37

開源部署流水線Jenkins

2017-09-06 16:08:45

JmeterJenkins自動化測試

2021-02-25 07:10:57

SonarQube代碼掃描代碼基線

2025-02-13 07:58:21

CI/CDJenkinsGitLab

2015-10-08 10:55:23

云服務自動化運維 ANSIBLE

2015-05-25 19:34:06

KickstartCentOS

2021-09-07 09:00:00

開發測試工具

2023-06-30 09:46:00

服務物理機自動化

2023-07-26 18:38:17

Json提效全量

2021-09-03 09:56:18

鴻蒙HarmonyOS應用

2023-04-06 07:09:25

自動化部署Actions

2021-03-18 14:47:42

Jenkins git submodu代碼

2023-03-29 08:33:03

倉儲自動化系統

2015-10-20 17:12:58

SuSE自動化運維運維

2023-11-15 18:02:52

2022-08-26 09:51:33

Web前端自動化

2024-03-05 09:39:03

Zadig版本管理版本

2025-06-20 02:11:00

2022-02-21 11:24:14

代碼工具開發

2013-11-27 11:34:43

自動化部署Python
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 久久久激情视频 | 中文字幕在线一区二区三区 | 色一情一乱一伦一区二区三区 | 黑色丝袜三级在线播放 | 免费黄色特级片 | 久草免费视 | 欧美日韩在线观看一区 | 亚洲成人午夜电影 | 在线欧美日韩 | 2021天天躁夜夜看 | 国产丝袜一区二区三区免费视频 | 天天草天天 | 在线观看毛片网站 | 久久精品性视频 | 久久伊人精品一区二区三区 | 国产一区二区三区四区 | 久久久久国产一区二区三区 | 国产aa| 国产成人精品在线播放 | 欧美一区二区三区四区五区无卡码 | 欧美一级淫片免费视频黄 | 青青草综合网 | 男女视频免费 | 国产在线对白 | 韩日在线视频 | 亚洲日本中文 | 涩爱av一区二区三区 | 欧美在线不卡 | 伊色综合久久之综合久久 | 福利久久| 在线观看日本高清二区 | 在线国产精品一区 | 精品国产一区二区在线 | 最新国产精品精品视频 | 国产sm主人调教女m视频 | 精品国产一区二区三区久久影院 | 精品久久久久国产免费第一页 | 999免费网站 | 国产精品视频一 | 国产成人jvid在线播放 | 久久久久精|