File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ # Create a new release with Jenkins Pipelines
2+
3+ For this we are using the modern approach of [ declarative pipelines] ( https://www.jenkins.io/doc/book/pipeline/ ) .
4+
5+ You must also ensure your jenkins instance supports docker.
6+ Most modern jenkins systems do have support for it, [ they have embraced it] ( https://www.jenkins.io/doc/book/pipeline/docker/ ) .
7+
8+ ``` groovy
9+ pipeline {
10+ agent {
11+ any
12+ }
13+ environment {
14+ CI = 'true'
15+ }
16+ stages {
17+ stage('Bump version') {
18+ when {
19+ beforeAgent true
20+ branch 'master'
21+ not {
22+ changelog '^bump:.+'
23+ }
24+ }
25+ steps {
26+ script {
27+ useCz {
28+ sh "cz bump --changelog"
29+ }
30+ // Here push back to your repository the new commit and tag
31+ }
32+ }
33+ }
34+ }
35+ }
36+
37+ def useCz(String authorName = 'Jenkins CI Server', String authorEmail = '[email protected] ', String image = 'registry.hub.docker.com/commitizen/commitizen:latest', Closure body) { 38+ docker
39+ .image(image)
40+ .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}'") {
41+ sh "git config --global user.email '${authorName}'"
42+ sh "git config --global user.name '${authorEmail}'"
43+ body()
44+ }
45+ }
46+ ```
47+
48+ !!! warning
49+ Using jenkins pipeline with any git plugin may require many different configurations,
50+ you'll have to tinker with it until your pipelines properly detects git events. Check your
51+ webhook in your git repository and check the "behaviors" and "build strategies" in
52+ your pipeline settings.
Original file line number Diff line number Diff line change 2121 - Writing commits : ' tutorials/writing_commits.md'
2222 - GitLab CI : ' tutorials/gitlab_ci.md'
2323 - Github Actions : ' tutorials/github_actions.md'
24+ - Jenkins pipeline : ' tutorials/jenkins_pipeline.md'
2425 - FAQ : ' faq.md'
2526 - Exit Codes : ' exit_codes.md'
2627 - Third-Party Commitizen Templates : ' third-party-commitizen.md'
You can’t perform that action at this time.
0 commit comments