@@ -13,27 +13,28 @@ ms.date: 11/15/2018
13
13
14
14
This tutorial deploys a sample Java web app from GitHub to
15
15
[ Azure App Service on Linux] ( /azure/app-service/containers/app-service-linux-intro )
16
- by setting up continuous integration (CI) and continuous deployment (CD) in Jenkins.
17
- That way, when you update your app by pushing commits to GitHub,
18
- Jenkins automatically builds and republishes your app to Azure App Service.
19
- The sample app in this tutorial was developed by using the
16
+ by setting up continuous integration (CI) and continuous
17
+ deployment (CD) in Jenkins. When you update the app by
18
+ pushing commits to GitHub, Jenkins automatically builds
19
+ and republishes your app to Azure App Service. The sample
20
+ app in this tutorial was developed by using the
20
21
[ Spring Boot] ( http://projects.spring.io/spring-boot/ ) framework.
21
22
22
23
![ Overview] ( media/jenkins-java-quickstart/overview.png )
23
24
24
25
In this tutorial, you'll complete these tasks:
25
26
26
27
> [ !div class="checklist"]
27
- > * Install Jenkins plug-ins so you can work with GitHub,
28
+ > * Install Jenkins plug-ins so you can build from GitHub,
28
29
> deploy to Azure App Service, and other related tasks.
29
- > * Fork the GitHub sample repo so you have a copy for the sample app .
30
+ > * Fork the sample GitHub repo so you have a working copy .
30
31
> * Connect Jenkins to GitHub.
31
- > * Create an Azure service principal for authentication
32
- > without using your own credentials.
33
- > * Set up your Azure service principal in Jenkins.
34
- > * Create a Jenkins pipeline that builds and deploys the sample app
35
- > app each time you push an update to the sample app in GitHub.
36
- > * Create a build and deployment script for your Jenkins pipeline.
32
+ > * Create an Azure service principal so Jenkins
33
+ > can access Azure without using your credentials.
34
+ > * Add your service principal to Jenkins.
35
+ > * Create a Jenkins pipeline for building and deploying
36
+ > the sample app each time you update the app in GitHub.
37
+ > * Create a build and deployment script that your Jenkins pipeline can use .
37
38
> * Point your Jenkins pipeline at the build and deployment script.
38
39
> * Deploy your sample app to Azure by running a manual build.
39
40
> * Push an app update in GitHub, which triggers Jenkins to build and redeploy to Azure.
@@ -95,6 +96,8 @@ the Jenkins management page for future steps.
95
96
96
97
1 . Follow the prompts to select your GitHub account and finish forking.
97
98
99
+ Next, set up Jenkins with your GitHub credentials.
100
+
98
101
## Connect Jenkins to GitHub
99
102
100
103
To have Jenkins monitor GitHub and respond when new
@@ -144,15 +147,18 @@ by choosing **Test connection**.
144
147
145
148
![ Check connection to GitHub server with new PAT] ( media/jenkins-java-quickstart/check-github-connection.png )
146
149
150
+ Next, create the Azure service principal that Jenkins
151
+ uses for authenticating and accessing Azure resources.
152
+
147
153
## Create service principal
148
154
149
- Later in this tutorial , you create a Jenkins pipeline job that builds
155
+ In a later section , you create a Jenkins pipeline job that builds
150
156
your app from GitHub and deploys your app to Azure App Service.
151
- To have Jenkins work access Azure without entering your credentials,
152
- create a [ service principal in Azure Active Directory ] ( https://docs.microsoft.com/azure/active-directory/develop/app-objects-and-service-principals ) .
153
- A service principal is a separate identity that Jenkins
154
- can use for authenticating and accessing Azure resources.
155
- To create this service principal, run the Azure CLI command
157
+ To have Jenkins access Azure without entering your credentials,
158
+ create a [ service principal] ( https://docs.microsoft.com/azure/active-directory/develop/app-objects-and-service-principals )
159
+ in Azure Active Directory for Jenkins. A service principal is
160
+ a separate identity that Jenkins can use for authenticating access
161
+ to Azure resources. To create this service principal, run the Azure CLI command
156
162
[ ** ` az ad sp create-for-rbac ` ** ] ( https://docs.microsoft.com/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest ) ,
157
163
either from your local command line or Azure Cloud Shell, for example:
158
164
@@ -198,7 +204,7 @@ select **Global credentials (unrestricted)**.
198
204
1 . From the ** Kind** list, select ** Azure Service Principal** .
199
205
200
206
1 . Assign these values from your service principal
201
- and elsewhere to these credential properties:
207
+ and Azure subscription to these properties:
202
208
203
209
| Property | Value | Description |
204
210
| ----------| -------| -------------|
@@ -213,11 +219,12 @@ and elsewhere to these credential properties:
213
219
214
220
![ Add Azure service principal credentials] ( media/jenkins-java-quickstart/add-service-principal-credentials.png )
215
221
216
- 1 . To confirm your service principal works,
217
- choose ** Verify Service Principal** .
218
- When you're done, choose ** OK** .
222
+ 1 . To confirm that your service principal works,
223
+ choose ** Verify Service Principal** . When you're done, choose ** OK** .
219
224
220
- ## Create build and deploy pipeline
225
+ Next, create the Jenkins pipeline that builds and deploys your app.
226
+
227
+ ## Create pipeline
221
228
222
229
In Jenkins, create the pipeline job for building and deploying your app.
223
230
@@ -247,17 +254,21 @@ can deploy to Azure without using your own credentials.
247
254
WEB_APP=yourWebAppName
248
255
```
249
256
250
- Here's how the **Properties Content** box appears when you're done :
257
+ Here's how the **Properties Content** box appears:
251
258
252
259

253
260
254
261
1. When you're done, choose **Save**.
255
262
256
- ## Create build and deploy scripts
263
+ Next, create build and deployment scripts for Jenkins.
264
+
265
+ ## Create scripts
257
266
258
- 1. In your GitHub fork's `src/main/resources/` folder,
259
- create a config file named `web.config` that contains this XML
260
- but replaces `$(JAR_FILE_NAME)` with `gs-spring-boot-0.1.0.jar`:
267
+ Now create the files that Jenkins uses for building and deploying your app.
268
+
269
+ 1. In your GitHub fork's `src/main/resources/` folder, create this
270
+ app configuration file named `web.config`, which contains this XML
271
+ but replace `$(JAR_FILE_NAME)` with `gs-spring-boot-0.1.0.jar`:
261
272
262
273
```xml
263
274
<?xml version="1.0" encoding="UTF-8">
@@ -266,14 +277,13 @@ but replaces `$(JAR_FILE_NAME)` with `gs-spring-boot-0.1.0.jar`:
266
277
<handlers>
267
278
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
268
279
</handlers>
269
- <httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
270
- arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\${JAR_FILE_NAME}""></httpPlatform>
280
+ <httpPlatform processPath="%JAVA_HOME%\bin\java.exe" arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\${JAR_FILE_NAME}""></httpPlatform>
271
281
</system.webServer>
272
282
</configuration>
273
283
```
274
284
275
- 1 . In your GitHub fork's root folder, create a build and deployment
276
- script named ` Jenkinsfile ` that contains this text
285
+ 1 . In your GitHub fork's root folder, create this build and
286
+ deployment script named ` Jenkinsfile ` , which contains this text
277
287
([ source in GitHub here] ( https://github.com/Microsoft/todo-app-java-on-azure/blob/master/doc/resources/jenkins/Jenkinsfile-webapp-se ) ):
278
288
279
289
``` text
@@ -326,13 +336,13 @@ select **Pipeline script from SCM**.
326
336
1 . In the ** Script Path** box,
327
337
add the path to your "Jenkinsfile" script.
328
338
329
- 1 . When you're done, choose ** Save ** .
339
+ Your pipeline definition looks like this example:
330
340
331
- For example:
341
+ ![ Point pipeline at script ] ( media/jenkins-java-quickstart/set-up-jenkins-github.png )
332
342
333
- ![ Point pipeline at script ] ( media/jenkins-java-quickstart/set-up-jenkins-github.png )
343
+ 1 . When you're done, choose ** Save ** .
334
344
335
- Next, you'll build and deploy your app to Azure App Service.
345
+ Next, build and deploy your app to Azure App Service.
336
346
337
347
## Build and deploy to Azure
338
348
0 commit comments