Table of contents 2
Intro 6
Authors 6
What is this book about? 6
Why Jenkins and GitLab 8
Structure of this book 8
About DevOps 9
Business challenges 9
Waterfall, Agile, DevOps 9
CI/CD 10
DevOps tools 11
Requirements 12
You as a reader 12
Hardware requirements 12
Software requirements 12
VirtualBox installation 13
Vagrant installation 14
Installing Git client 14
Verification 14
Lab environment overview 15
Getting started with GitLab 20
Git repository management 20
GitHub 20
GitLab 21
BitBucket 21
GitLab, GitHub, and BitBucket comparison 22
Git 22
GitLab installation 23
Connecting to GitLab 25
Git basics 33
Using Git help 34
Working with Git 35
Sharing git projects 41
Working with merge requests 50
Getting started with Jenkins 59
About Jenkins 59
Installing Jenkins 59
Pipelines overview 66
Creating Jenkins Pipeline 67
Groovy - Basics 70
Node 71
Stage 72
Step 73
Input 76
Pipelines - advanced syntax 80
Variables 80
Functions 82
Variable + Function() == LOVE 92
For loops 93
Try, catch, finally 96
If, else if, else 98
Switch case 102
Retry 105
Parallel 108
Configuring Jenkins 109
Installing plugins 110
Updates 111
Available 112
Installed 115
Adding new users 116
Jenkins and GitLab API 120
Why API? 120
API access tools 120
Using curl to access APIs 120
Formatting output using jq 122
Using GitLab API 124
GitLab API 124
Authentication 124
API Status codes 127
Managing GitLab projects 127
List projects 127
Get single project 130
Create a project 131
Update project settings 133
Delete project 134
Other project-related activities 135
Managing GitLab users 135
Managing branches 139
Managing merge requests 141
Managing other GitLab entities 146
Using Jenkins API 147
Jenkins API 147
Authentication 149
List jobs 152
Create a Job 153
Trigger a build 156
Making GitLab and Jenkins to work together 157
Why we need it 157
What we want to achieve 157
Moving Jenkins pipelines to GitLab 157
Create a GitLab repo with pipeline script 158
Install git on Jenkins 160
Create Jenkins job 161
Triggering Jenkins job automatically 168
Configuring Jenkins build triggers 168
Using GitLab Jenkins plugin 171
Install GitLab Jenkins plugin 171
Configuring Jenkins to GitLab authentication 173
Configuring GitLab to Jenkins authentication 174
Automatic job triggering via GitLab 177
Allowing remote API calls to Jenkins 177
Configuring GitLab Webhooks 178
Update repository files 181
Updating GitLab progress from Jenkins 182
gitlabBuilds 182
gitlabCommitStatus 183
Integrating Jenkins pipelines with merge requests 186
Application 186
Configure GitLab WebHook 186
Configure GitLab merge settings 187
Configure Jenkins job parameters 188
Creating a merge request 189
More options of integration 194
Conclusions 195