1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| pipeline { agent any options { timestamps() } environment { TimeStamp="${currentBuild.startTimeInMillis}" Service="${JOB_BASE_NAME}" Branch="${env.gitlabTargetBranch}" } parameters { choice(name: 'Action',choices: '程序发版\n程序回滚',description: '请选择操作') choice(name: 'Scope',choices: '开发环境\n测试环境\n预发环境\n生产环境',description: '请选择部署环境') string(name: 'BranchOrTag', defaultValue: '', description: '指定分支或tag发版,默认请不要填写。') } stages { stage('PrintEnv') { steps { sh "printenv" } } } post { success { script { if ( "${Branch}" == 'null' ) { dingtalk( robot: '0c5dda39-f5e0-40ca-bdbc-3ba473fcc4f3', type:'MARKDOWN', atAll: false, text: [ "# 发版成功:${JOB_BASE_NAME}", '---', "- 服务名称:${JOB_BASE_NAME}", "- 发版环境:${Scope}", "- 发版方式:手动", "- 任务ID:[${BUILD_ID}](${RUN_DISPLAY_URL})" ] ) } else { dingtalk( robot: '0c5dda39-f5e0-40ca-bdbc-3ba473fcc4f3', type:'MARKDOWN', atAll: false, text: [ "# 发版成功:${JOB_BASE_NAME}", '---', "- 发版环境:${Scope}", "- 服务名称:${JOB_BASE_NAME}", "- 发版方式:GitLab WebHook", "- 任务ID:[${BUILD_ID}](${RUN_DISPLAY_URL})" ] ) } } } failure { script { if ( "${Branch}" == 'null' ) { dingtalk( robot: '0c5dda39-f5e0-40ca-bdbc-3ba473fcc4f3', type:'MARKDOWN', atAll: false, text: [ "# 发版失败:${JOB_BASE_NAME}", '---', "- 服务名称:${JOB_BASE_NAME}", "- 发版环境:${Scope}", "- 发版方式:手动", "- 任务ID:[${BUILD_ID}](${RUN_DISPLAY_URL})" ] ) } else { dingtalk( robot: '0c5dda39-f5e0-40ca-bdbc-3ba473fcc4f3', type:'MARKDOWN', atAll: false, text: [ "# 发版失败:${JOB_BASE_NAME}", '---', "- 发版环境:${Scope}", "- 服务名称:${JOB_BASE_NAME}", "- 发版方式:GitLab WebHook", "- 任务ID:[${BUILD_ID}](${RUN_DISPLAY_URL})" ] ) } } } } }
|