Skip to content

Commit 3b07f53

Browse files
woileLee-W
authored andcommitted
docs: add new jenkins tutorial
Closes #78
1 parent 86a6c50 commit 3b07f53

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

‎docs/tutorials/jenkins_pipeline.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 = 'your-jenkins@email.com', 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.

‎mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ nav:
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'

0 commit comments

Comments
 (0)