├── .gitignore ├── LICENSE ├── README.md ├── ci ├── 2-envs.yml ├── 3-envs.yml ├── params.yml.sample └── tasks │ ├── e2e.sh │ ├── e2e.yml │ ├── integration.sh │ ├── integration.yml │ ├── merge-branch.yml │ ├── merge.sh │ ├── shipit.sh │ ├── shipit.yml │ ├── unit.sh │ └── unit.yml └── images ├── 2-envs.png └── 3-envs.png /.gitignore: -------------------------------------------------------------------------------- 1 | params.yml 2 | .DS_STORE 3 | 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Shingo Omura 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # concourse-gitlab-flow 2 | This repository has two concourse pipeline examples supporting two [Gitlab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html) model below: 3 | 4 | * [Production branch with GitLab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html#production-branch-with-gitlab-flow) 5 | * [Environment branches with GitLab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html#environment-branches-with-gitlab-flow) 6 | 7 | # [Production branch with GitLab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html#production-branch-with-gitlab-flow) 8 | [Production branch with Gitlab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html#production-branch-with-gitlab-flow) assumes two major branches. 9 | 10 | * `main` branch: This branch is for tracking production 'grade' code, it can be seen as release candidates. Not as github flow, master branch is not for tracking production codes. 11 | * features branch: as standard git flow and github flow, this is for developing each feature and will be merged to master. 12 | * `production` branch: This is the branch for tracking production code. Every commit on the branch will be shipped to the production environment. 13 | 14 | ## [Concourse pipeline to support "Production branch with Gitlab flow"](ci/2-envs.yaml) 15 | ![2-envs.yml](images/2-envs.png) 16 | 17 | [2-envs.yml](ci/2-envs.yml) supports that: 18 | * Semantic versioning by [semver-resource](https://github.com/concourse/semver-resource) 19 | * Continuous Integration(CI) for pull requests. 20 | * Continuous Deployment(CD) of `master` branch 21 | * deployment to `staging` environment bumps release candidate version (stored in `rc-version` resource) 22 | * release candidate version will be of the form `x.y.z-rc.n` 23 | * CI/CD of `production` branch 24 | * `merge-master-to-production` job is the trigger to start deployment to production. 25 | * Succeeding jobs performs CI/CD 26 | * `version-production` job always computes final version from `rc-version` resource and stores it to `final-version` resource. 27 | * If release candidate version was `x.y.z-rc.n`, final version will be `x.y.z` 28 | * `start-next-rc` is executed after `tag-production`. This stores next release candidate version to `rc-version` resource. 29 | * If `x.y.z` will be tagged, `start-next-rc` bumped patch version. i.e. in this case, next release candidate version will be `x.y.(z+1)-dev.1` 30 | * Team can manually bump minor/major version when big changes happened on master branch. 31 | * tagging commits and actual shipment jobs are separated. This enables you to ship the latest commit on production branch to production environment __without__ bumping versions. This would be useful for deployment failure or network issues. 32 | 33 | Please note that this pipeline does NOT support hotfix-ing on `production` branch. This means you need to commits those fixes to master branch and start over release process. See [2-envs.yml](ci/2-envs.yml) for implementation details. 34 | 35 | 36 | 37 | 38 | # [Environment branches with GitLab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html#environment-branches-with-gitlab-flow) 39 | In [Environment branches with GitLab flow](http://docs.gitlab.com/ee/workflow/gitlab_flow.html#environment-branches-with-gitlab-flow), it assumes three environment. They are `staging`, `pre-production`, `production` environments. It also assumes git repository have three major branches whose are corresponding to environments. Please note that `master` branch is the only branch whose name is different from environment name. 40 | 41 | * `main` branch: This branch is for tracking codes which are deployed continuously to `staging` environment. 42 | * features branch: as standard git flow and github flow, this is for developing each feature and will be merged to master. 43 | * `pre-production` branch: This branch if for tracking codes which are deployed to `pre-production` environment. Every commit on the branch will be shipped to the pre-production environment. These shipment can be seen as release candidates. 44 | * `prodution` branch: This is the branch for tracking production code. Every commit on the branch will be shipped to the production environment. 45 | 46 | ## [Concourse pipeline to support "Environment branches with Gitlab flow"](ci/3-envs.yaml) 47 | 48 | ![3-envs.yml](images/3-envs.png) 49 | 50 | [3-envs.yml](ci/3-envs.yml) supports that: 51 | * Semantic versioning by [semver-resource](https://github.com/concourse/semver-resource) 52 | * Continuous Integration(CI) for pull requests. 53 | * Continuous Deployment(CD) to `staging` environment of master branch. 54 | * deployment to `staging` environment bumps development version (`dev-version` resource) 55 | * development version will be of the form `x.y.z-dev.n` 56 | * CI/CD of `pre-production` branch 57 | * `merge-master-to-pre-production` job is the trigger to start deployment to `pre-production` environment. 58 | * Succeeding jobs performs CI/CD to `pre-production` environment. 59 | * `version-pre-production` job always computes release candidate version from `dev-version` resource and stores it to `rc-version` resource. 60 | * If development version was `x.y.z-dev.n`, release candidate version will be `x.y.z-rc.1` 61 | * `start-next-dev` is executed after `tag-pre-production`. This stores next development version to `dev-version` resource. 62 | * If `x.y.z-rc.1` will be tagged, `start-next-dev` bumped patch version. Next dev version will be `x.y.(z+1)-dev.1` 63 | * This means release candidate version will never be bumped to `rc.2`. Team needs to fix commits on mater branch and start over CI/CD flow from `merge-master-to-pre-production` 64 | * Team can manually bump patch/minor/master branch when big changes happened on master branch. 65 | * `e2e-test-on-pre-production` performs end-to-end test on `pre-production` environment. This would work as the final gate to promote pre-production branch to production branch. 66 | * CI/CD of `production` branch 67 | * When `e2e-test-on-pre-production` passed, CI/CD process of production branch will be triggered automatically. `merge-pre-production-to-production` will be kicked. 68 | * Succeeding jobs performs CI/CD to `production` environment. 69 | * `version-production` job always computes final version from `rc-version` resource and stores it to `final-version` resource. 70 | * If release candidate version was `x.y.z-rc.1`, final version will be `x.y.z` 71 | * tagging and actual shipment jobs are separated. This enables you to ship the latest commit on production branch to production environment __without__ bumping versions. This would be useful for deployment failure or network issues. 72 | 73 | Please note that this pipeline does NOT support hotfix-ing on `pre-production` and `production` branch. This means you need to commits those fixes to master branch and start over release process. See [3-envs.yml](ci/3-envs.yml) for detailed. 74 | -------------------------------------------------------------------------------- /ci/2-envs.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: master 3 | jobs: 4 | - test-pr 5 | - test-master 6 | - integrate-master 7 | - version-master 8 | - ship-master 9 | - patch 10 | - minor 11 | - major 12 | - rc 13 | 14 | - name: production 15 | jobs: 16 | - merge-master-to-production 17 | - test-production 18 | - version-production 19 | - tag-production 20 | - ship-production 21 | - start-next-rc 22 | 23 | resource_types: 24 | - name: pull-request 25 | type: docker-image 26 | source: 27 | repository: jtarchie/pr 28 | 29 | resources: 30 | - name: repo-master 31 | type: git 32 | source: 33 | uri: {{github-repo-uri}} 34 | branch: master 35 | private_key: {{github-private-key}} 36 | 37 | - name: repo-production 38 | type: git 39 | source: 40 | uri: {{github-repo-uri}} 41 | branch: production 42 | private_key: {{github-private-key}} 43 | 44 | - name: pull-request 45 | type: pull-request 46 | source: 47 | access_token: {{github-access-token}} 48 | private_key: {{github-private-key}} 49 | repo: {{github-repo-name}} 50 | every: true 51 | 52 | - name: rc-version 53 | type: semver 54 | source: 55 | driver: git 56 | uri: {{github-repo-uri}} 57 | branch: version/rc 58 | private_key: {{github-private-key}} 59 | file: version 60 | initial_version: {{initial-version}} 61 | 62 | - name: final-version 63 | type: semver 64 | source: 65 | driver: git 66 | uri: {{github-repo-uri}} 67 | branch: version/final 68 | private_key: {{github-private-key}} 69 | file: rc-version 70 | initial_version: {{initial-version}} 71 | 72 | jobs: 73 | - name: test-pr 74 | plan: 75 | - get: pull-request 76 | resource: pull-request 77 | version: every 78 | trigger: true 79 | - put: pull-request 80 | params: 81 | path: pull-request 82 | status: pending 83 | - task: test-pull-request 84 | file: pull-request/ci/tasks/unit.yml 85 | input_mapping: { repo: pull-request } 86 | on_success: 87 | put: pull-request 88 | params: 89 | path: pull-request 90 | status: success 91 | on_failure: 92 | put: pull-request 93 | params: 94 | path: pull-request 95 | status: failure 96 | 97 | - name: test-master 98 | plan: 99 | - get: master 100 | resource: repo-master 101 | trigger: true 102 | - task: unit 103 | file: master/ci/tasks/unit.yml 104 | input_mapping: { repo: master } 105 | 106 | - name: integrate-master 107 | serial: true 108 | plan: 109 | - aggregate: 110 | - get: master 111 | resource: repo-master 112 | trigger: true 113 | passed: [ test-master ] 114 | - task: integration-test 115 | file: master/ci/tasks/integration.yml 116 | input_mapping: {repo: master} 117 | 118 | - name: version-master 119 | serial: true 120 | serial_groups: [ update-version ] 121 | plan: 122 | - aggregate: 123 | - get: master 124 | resource: repo-master 125 | trigger: true 126 | passed: [ integrate-master] 127 | - get: rc-version 128 | - put: rc-version 129 | params: { pre: rc } 130 | 131 | - name: ship-master 132 | serial: true 133 | plan: 134 | - aggregate: 135 | - get: master 136 | resource: repo-master 137 | trigger: true 138 | passed: [ version-master ] 139 | - get: rc-version 140 | passed: [ version-master ] 141 | - task: ship 142 | file: master/ci/tasks/shipit.yml 143 | input_mapping: { repo: master, version: rc-version } 144 | 145 | - name: merge-master-to-production 146 | serial: true 147 | plan: 148 | - aggregate: 149 | - get: master 150 | resource: repo-master 151 | passed: [ ship-master ] 152 | - get: production 153 | resource: repo-production 154 | - task: merge-master-to-production 155 | file: master/ci/tasks/merge-branch.yml 156 | input_mapping: { from: master, to: production } 157 | output_mapping: { out: next-production } 158 | params: 159 | GIT_EMAIL: {{git-email}} 160 | GIT_NAME: {{git-name}} 161 | NO_FF: true 162 | - put: production 163 | resource: repo-production 164 | params: 165 | repository: next-production 166 | 167 | - name: test-production 168 | serial: true 169 | plan: 170 | - get: production 171 | resource: repo-production 172 | # This pipeline assumes upstream-first branching model. 173 | # i.e It doesn't support hot fix. 174 | # Please commit on master branch and 175 | # start over from merge-master-to-pre-production. 176 | passed: [ merge-master-to-production ] 177 | trigger: true 178 | - task: unit-on-production 179 | file: production/ci/tasks/unit.yml 180 | input_mapping: { repo: production } 181 | 182 | - name: version-production 183 | serial: true 184 | plan: 185 | - aggregate: 186 | - get: production 187 | resource: repo-production 188 | passed: [ test-production ] 189 | trigger: true 190 | - get: rc-version 191 | params: { bump: final } 192 | - put: final-version 193 | params: { file: rc-version/version } 194 | 195 | - name: tag-production 196 | serial: true 197 | plan: 198 | - aggregate: 199 | - get: production 200 | resource: repo-production 201 | passed: [ version-production ] 202 | trigger: true 203 | - get: final-version 204 | passed: [ version-production ] 205 | - put: production 206 | resource: repo-production 207 | params: 208 | repository: production 209 | tag: final-version/version 210 | 211 | - name: ship-production 212 | serial: true 213 | plan: 214 | - get: production 215 | resource: repo-production 216 | passed: [ tag-production ] 217 | #Uncomment this line for CD 218 | #trigger: true 219 | - get: final-version 220 | passed: [ tag-production ] 221 | - task: ship-production 222 | file: production/ci/tasks/shipit.yml 223 | input_mapping: { repo: production, version: final-version } 224 | 225 | - name: start-next-rc 226 | serial: true 227 | serial_groups: [ update-version ] 228 | plan: 229 | - get: final-version 230 | passed: [ tag-production ] 231 | trigger: true 232 | params: { bump: patch } 233 | # This initializes rc-verison with version 234 | # of the form 'x.y.z' temporalily. 235 | # However, we can gurantee that tagged versions on master branch 236 | # will be of the form 'x.y.z-rc.n' because version-master always 237 | # bump with {pre: rc}. 238 | - put: rc-version 239 | params: { file: final-version/version } 240 | 241 | 242 | # semver control 243 | # As start-next-rc job above, 244 | # these semver controll jobs initialize rc-verison with version 245 | # of the form 'x.y.z' temporalily. 246 | # However, we can gurantee that tagged versions on master branch 247 | # will be of the form 'x.y.z-rc.n' because version-master always 248 | # bump with {pre: rc}. 249 | - name: patch 250 | serial: true 251 | serial_groups: [ update-version ] 252 | plan: 253 | - get: rc-version 254 | - put: rc-version 255 | params: { bump: patch } 256 | 257 | - name: minor 258 | serial: true 259 | serial_groups: [ update-version ] 260 | plan: 261 | - get: rc-version 262 | - put: rc-version 263 | params: { bump: minor } 264 | 265 | - name: major 266 | serial: true 267 | serial_groups: [ update-version ] 268 | plan: 269 | - get: rc-version 270 | - put: rc-version 271 | params: { bump: major } 272 | 273 | - name: rc 274 | serial: true 275 | serial_groups: [ update-version ] 276 | plan: 277 | - get: rc-version 278 | - put: rc-version 279 | params: { pre: rc } 280 | -------------------------------------------------------------------------------- /ci/3-envs.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: staging(master) 3 | jobs: 4 | - test-pr 5 | - test-master 6 | - integrate-master 7 | - version-master 8 | - tag-master 9 | - ship-master 10 | - patch 11 | - minor 12 | - major 13 | - dev 14 | 15 | - name: pre-production 16 | jobs: 17 | - merge-master-to-pre-production 18 | - start-next-dev 19 | - test-pre-production 20 | - integrate-pre-production 21 | - version-pre-production 22 | - tag-pre-production 23 | - ship-pre-production 24 | - e2e-test-on-pre-production 25 | 26 | - name: production 27 | jobs: 28 | - e2e-test-on-pre-production 29 | - merge-pre-production-to-production 30 | - test-production 31 | - version-production 32 | - tag-production 33 | - ship-production 34 | 35 | resource_types: 36 | - name: pull-request 37 | type: docker-image 38 | source: 39 | repository: jtarchie/pr 40 | 41 | resources: 42 | - name: repo-master 43 | type: git 44 | source: 45 | uri: {{github-repo-uri}} 46 | branch: master 47 | private_key: {{github-private-key}} 48 | 49 | - name: repo-pre-production 50 | type: git 51 | source: 52 | uri: {{github-repo-uri}} 53 | branch: pre-production 54 | private_key: {{github-private-key}} 55 | 56 | - name: repo-production 57 | type: git 58 | source: 59 | uri: {{github-repo-uri}} 60 | branch: production 61 | private_key: {{github-private-key}} 62 | 63 | - name: pull-request 64 | type: pull-request 65 | source: 66 | access_token: {{github-access-token}} 67 | private_key: {{github-private-key}} 68 | repo: {{github-repo-name}} 69 | every: true 70 | 71 | - name: dev-version 72 | type: semver 73 | source: 74 | driver: git 75 | uri: {{github-repo-uri}} 76 | branch: version/dev 77 | private_key: {{github-private-key}} 78 | file: version 79 | initial_version: {{initial-version}} 80 | 81 | - name: rc-version 82 | type: semver 83 | source: 84 | driver: git 85 | uri: {{github-repo-uri}} 86 | branch: version/rc 87 | private_key: {{github-private-key}} 88 | file: version 89 | initial_version: {{initial-version}} 90 | 91 | - name: final-version 92 | type: semver 93 | source: 94 | driver: git 95 | uri: {{github-repo-uri}} 96 | branch: version/final 97 | private_key: {{github-private-key}} 98 | file: rc-version 99 | initial_version: {{initial-version}} 100 | 101 | jobs: 102 | - name: test-pr 103 | plan: 104 | - get: pull-request 105 | resource: pull-request 106 | version: every 107 | trigger: true 108 | - put: pull-request 109 | params: 110 | path: pull-request 111 | status: pending 112 | - task: test-pull-request 113 | file: pull-request/ci/tasks/unit.yml 114 | input_mapping: { repo: pull-request } 115 | on_success: 116 | put: pull-request 117 | params: 118 | path: pull-request 119 | status: success 120 | on_failure: 121 | put: pull-request 122 | params: 123 | path: pull-request 124 | status: failure 125 | 126 | - name: test-master 127 | plan: 128 | - get: master 129 | resource: repo-master 130 | trigger: true 131 | - task: unit 132 | file: master/ci/tasks/unit.yml 133 | input_mapping: { repo: master } 134 | 135 | - name: integrate-master 136 | serial: true 137 | plan: 138 | - aggregate: 139 | - get: master 140 | resource: repo-master 141 | trigger: true 142 | passed: [ test-master ] 143 | - task: integration-test 144 | file: master/ci/tasks/integration.yml 145 | input_mapping: {repo: master} 146 | 147 | - name: version-master 148 | serial: true 149 | serial_groups: [ update-version ] 150 | plan: 151 | - aggregate: 152 | - get: master 153 | resource: repo-master 154 | trigger: true 155 | passed: [ integrate-master ] 156 | - get: dev-version 157 | - put: dev-version 158 | params: { pre: dev } 159 | 160 | - name: tag-master 161 | serial: true 162 | plan: 163 | - aggregate: 164 | - get: master 165 | resource: repo-master 166 | - get: dev-version 167 | passed: [ version-master ] 168 | trigger: true 169 | - put: master 170 | resource: repo-master 171 | params: 172 | repository: master 173 | tag: dev-version/version 174 | 175 | - name: ship-master 176 | serial: true 177 | plan: 178 | - aggregate: 179 | - get: master 180 | resource: repo-master 181 | trigger: true 182 | passed: [ tag-master ] 183 | - get: dev-version 184 | passed: [ tag-master ] 185 | - task: ship 186 | file: master/ci/tasks/shipit.yml 187 | input_mapping: { repo: master, version: dev-version } 188 | 189 | - name: merge-master-to-pre-production 190 | serial: true 191 | plan: 192 | - aggregate: 193 | - get: master 194 | resource: repo-master 195 | passed: [ ship-master ] 196 | # Uncomment to support automatic promotion 197 | # from master to pre-production 198 | # trigger: true 199 | - get: pre-production 200 | resource: repo-pre-production 201 | - get: dev-version 202 | params: { pre: rc } 203 | - task: merge-master-to-pre-production 204 | file: master/ci/tasks/merge-branch.yml 205 | input_mapping: { from: master, to: pre-production } 206 | output_mapping: { out: next-pre-production } 207 | params: 208 | GIT_EMAIL: {{git-email}} 209 | GIT_NAME: {{git-name}} 210 | NO_FF: true 211 | - put: pre-production 212 | resource: repo-pre-production 213 | params: 214 | repository: next-pre-production 215 | 216 | - name: test-pre-production 217 | serial: true 218 | plan: 219 | - get: pre-production 220 | resource: repo-pre-production 221 | # This pipeline assumes upstream-first branching model. 222 | # i.e It doesn't support hot fix. 223 | # Please commit on master branch and 224 | # start over from merge-master-to-pre-production. 225 | passed: [ merge-master-to-pre-production ] 226 | trigger: true 227 | - task: unit 228 | file: pre-production/ci/tasks/unit.yml 229 | input_mapping: { repo: pre-production } 230 | 231 | - name: integrate-pre-production 232 | serial: true 233 | plan: 234 | - aggregate: 235 | - get: pre-production 236 | resource: repo-pre-production 237 | trigger: true 238 | passed: [ test-pre-production ] 239 | - task: integration-test 240 | file: pre-production/ci/tasks/integration.yml 241 | input_mapping: {repo: pre-production } 242 | 243 | - name: version-pre-production 244 | serial: true 245 | plan: 246 | - aggregate: 247 | - get: pre-production 248 | resource: repo-pre-production 249 | passed: [ integrate-pre-production ] 250 | trigger: true 251 | - get: dev-version 252 | params: { bump: final, pre: rc } 253 | - put: rc-version 254 | params: { file: dev-version/version } 255 | 256 | - name: tag-pre-production 257 | serial: true 258 | plan: 259 | - aggregate: 260 | - get: pre-production 261 | resource: repo-pre-production 262 | passed: [ version-pre-production ] 263 | trigger: true 264 | - get: rc-version 265 | passed: [ version-pre-production ] 266 | - put: pre-production 267 | resource: repo-pre-production 268 | params: 269 | repository: pre-production 270 | tag: rc-version/version 271 | 272 | - name: start-next-dev 273 | serial: true 274 | serial_groups: [ update-version ] 275 | plan: 276 | - get: rc-version 277 | passed: [ tag-pre-production ] 278 | trigger: true 279 | params: { bump: patch } 280 | # This initializes dev-verison with version 281 | # of the form 'x.y.z' temporalily. 282 | # However, we can gurantee that tagged versions on master branch 283 | # will be of the form 'x.y.z-dev.n' because version-master always 284 | # bump with {pre: dev}. 285 | - put: dev-version 286 | params: { file: rc-version/version } 287 | 288 | - name: ship-pre-production 289 | serial: true 290 | plan: 291 | - get: pre-production 292 | resource: repo-pre-production 293 | passed: [ tag-pre-production ] 294 | #Uncomment this line for CD 295 | #trigger: true 296 | - get: rc-version 297 | passed: [ tag-pre-production ] 298 | - task: ship-pre-production 299 | file: pre-production/ci/tasks/shipit.yml 300 | input_mapping: { repo: pre-production, version: rc-version } 301 | 302 | - name: e2e-test-on-pre-production 303 | serial: true 304 | plan: 305 | - aggregate: 306 | - get: pre-production 307 | resource: repo-pre-production 308 | trigger: true 309 | passed: [ ship-pre-production ] 310 | - task: e2e-test 311 | file: pre-production/ci/tasks/e2e.yml 312 | input_mapping: { repo: pre-production } 313 | 314 | 315 | - name: merge-pre-production-to-production 316 | serial: true 317 | plan: 318 | - aggregate: 319 | - get: pre-production 320 | resource: repo-pre-production 321 | passed: [ e2e-test-on-pre-production ] 322 | trigger: true 323 | - get: production 324 | resource: repo-production 325 | - task: merge-pre-production-to-production 326 | file: pre-production/ci/tasks/merge-branch.yml 327 | input_mapping: { from: pre-production, to: production } 328 | output_mapping: { out: next-production } 329 | params: 330 | GIT_EMAIL: {{git-email}} 331 | GIT_NAME: {{git-name}} 332 | NO_FF: true 333 | - put: production 334 | resource: repo-production 335 | params: 336 | repository: next-production 337 | 338 | - name: test-production 339 | serial: true 340 | plan: 341 | - get: production 342 | resource: repo-production 343 | # This pipeline assumes upstream-first branching model. 344 | # i.e It doesn't support hot fix. 345 | # Please commit on master branch and 346 | # start over from merge-master-to-pre-production. 347 | passed: [ merge-pre-production-to-production ] 348 | trigger: true 349 | - task: unit-on-production 350 | file: production/ci/tasks/unit.yml 351 | input_mapping: { repo: production } 352 | 353 | - name: version-production 354 | serial: true 355 | plan: 356 | - aggregate: 357 | - get: production 358 | resource: repo-production 359 | passed: [ test-production ] 360 | trigger: true 361 | - get: rc-version 362 | params: { bump: final } 363 | - put: final-version 364 | params: { file: rc-version/version } 365 | 366 | - name: tag-production 367 | serial: true 368 | plan: 369 | - aggregate: 370 | - get: production 371 | resource: repo-production 372 | passed: [ version-production ] 373 | trigger: true 374 | - get: final-version 375 | passed: [ version-production ] 376 | - put: production 377 | resource: repo-production 378 | params: 379 | repository: production 380 | tag: final-version/version 381 | 382 | - name: ship-production 383 | serial: true 384 | plan: 385 | - get: production 386 | resource: repo-production 387 | passed: [ tag-production ] 388 | #Uncomment this line for CD 389 | #trigger: true 390 | - get: final-version 391 | passed: [ tag-production ] 392 | - task: ship-production 393 | file: production/ci/tasks/shipit.yml 394 | input_mapping: { repo: production, version: final-version } 395 | 396 | 397 | # semver control 398 | # As start-next-dev job above, 399 | # these semver controll jobs initialize dev-verison with version 400 | # of the form 'x.y.z' temporalily. 401 | # However, we can gurantee that tagged versions on master branch 402 | # will be of the form 'x.y.z-dev.n' because version-master always 403 | # bump with {pre: dev}. 404 | - name: patch 405 | serial: true 406 | serial_groups: [ update-version ] 407 | plan: 408 | - get: dev-version 409 | - put: dev-version 410 | params: { bump: patch } 411 | 412 | - name: minor 413 | serial: true 414 | serial_groups: [ update-version ] 415 | plan: 416 | - get: dev-version 417 | - put: dev-version 418 | params: { bump: minor } 419 | 420 | - name: major 421 | serial: true 422 | serial_groups: [ update-version ] 423 | plan: 424 | - get: dev-version 425 | - put: dev-version 426 | params: { bump: major } 427 | 428 | - name: dev 429 | serial: true 430 | serial_groups: [ update-version ] 431 | plan: 432 | - get: dev-version 433 | - put: dev-version 434 | params: { pre: dev } 435 | -------------------------------------------------------------------------------- /ci/params.yml.sample: -------------------------------------------------------------------------------- 1 | github-repo-uri: git@github.com:everpeace/concourse-gitlab-flow.git 2 | github-repo-name: everpeace/concourse-gitlab-flow 3 | 4 | github-access-token: xxx 5 | github-private-key: | 6 | xxx 7 | 8 | initial-version: 0.0.1-dev.1 9 | 10 | git-email: everpeace@gmail.com 11 | git-name: Shingo Omura 12 | -------------------------------------------------------------------------------- /ci/tasks/e2e.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # FIXME Customize it! 4 | echo "end2end testing on $(cd repo; git rev-parse HEAD)" 5 | exit 0; 6 | -------------------------------------------------------------------------------- /ci/tasks/e2e.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: docker-image 5 | source: 6 | repository: getourneau/alpine-bash-git 7 | inputs: 8 | - name: repo 9 | run: 10 | path: /bin/bash 11 | args: 12 | - repo/ci/tasks/e2e.sh 13 | -------------------------------------------------------------------------------- /ci/tasks/integration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # FIXME Customize it! 4 | echo "integration testing on $(cd repo; git rev-parse HEAD)" 5 | exit 0; 6 | -------------------------------------------------------------------------------- /ci/tasks/integration.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: docker-image 5 | source: 6 | repository: getourneau/alpine-bash-git 7 | inputs: 8 | - name: repo 9 | run: 10 | path: /bin/bash 11 | args: 12 | - repo/ci/tasks/integration.sh 13 | -------------------------------------------------------------------------------- /ci/tasks/merge-branch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: docker-image 5 | source: 6 | repository: getourneau/alpine-bash-git 7 | inputs: 8 | - name: from 9 | path: repo-target 10 | - name: to 11 | path: repo 12 | outputs: 13 | - name: out 14 | run: 15 | path: /bin/bash 16 | args: 17 | - repo-target/ci/tasks/merge.sh 18 | -------------------------------------------------------------------------------- /ci/tasks/merge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$DEBUG" = "true" ]; then 3 | set -x 4 | fi 5 | 6 | # repo-target: merge target 7 | # repo: current branch 8 | # out: output for push 9 | 10 | git config --global user.email "${GIT_EMAIL}" 11 | git config --global user.name "${GIT_NAME}" 12 | 13 | cd repo-target 14 | TARGET_BRANCH=$(git branch --contains | grep -v '('| sed 's/^\**[[:blank:]]*//g'| head -n 1) 15 | echo "merge target branch:${TARGET_BRANCH}" 16 | cd .. 17 | 18 | cd out 19 | shopt -s dotglob 20 | rm -rf * 21 | mv -f ../repo/* ./ 22 | GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git remote add -f repo-target ../repo-target 23 | 24 | CURRENT_BRANCH=$(git branch --contains | grep -v '('| sed 's/^\**[[:blank:]]*//g'| head -n 1) 25 | echo "current branch:${CURRENT_BRANCH}" 26 | 27 | MESSAGE="${MESSAGE:-[Concourse CI] Merge branch ${TARGET_BRANCH} into ${CURRENT_BRANCH}}" 28 | 29 | if [ "${CI_SKIP}" = "true" ]; then 30 | MESSAGE="[ci skip]${MESSAGE}" 31 | fi 32 | 33 | if [ "${NO_FF}" = "true" ]; then 34 | MERGE_MODE="--no-ff" 35 | else 36 | MERGE_MODE="--ff" 37 | fi 38 | 39 | echo "MESSAGE=${MESSAGE}" 40 | echo "MERGE_MODE=${MERGE_MODE}" 41 | git merge ${MERGE_MODE} "repo-target/${TARGET_BRANCH}" -m "${MESSAGE}" 42 | -------------------------------------------------------------------------------- /ci/tasks/shipit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION=$(cat version/version) 4 | 5 | # FIXME Customize it! 6 | echo "Shipping ${VERSION}." 7 | 8 | exit 0 9 | -------------------------------------------------------------------------------- /ci/tasks/shipit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: docker-image 5 | source: 6 | repository: getourneau/alpine-bash-git 7 | inputs: 8 | - name: repo 9 | - name: version 10 | run: 11 | path: /bin/bash 12 | args: 13 | - repo/ci/tasks/shipit.sh 14 | -------------------------------------------------------------------------------- /ci/tasks/unit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # FIXME Customize it! 4 | echo "unit testing on $(cd repo; git rev-parse HEAD)" 5 | exit 0; 6 | -------------------------------------------------------------------------------- /ci/tasks/unit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: docker-image 5 | source: 6 | repository: getourneau/alpine-bash-git 7 | inputs: 8 | - name: repo 9 | run: 10 | path: /bin/bash 11 | args: 12 | - repo/ci/tasks/unit.sh 13 | -------------------------------------------------------------------------------- /images/2-envs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everpeace/concourse-gitlab-flow/3c205f5b0b129e4cacf351cf12e44eebc5e8b1ca/images/2-envs.png -------------------------------------------------------------------------------- /images/3-envs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everpeace/concourse-gitlab-flow/3c205f5b0b129e4cacf351cf12e44eebc5e8b1ca/images/3-envs.png --------------------------------------------------------------------------------