diff --git a/11-pipeline-job.md b/11-pipeline-job.md index e69de29..1641b97 100644 --- a/11-pipeline-job.md +++ b/11-pipeline-job.md @@ -0,0 +1,108 @@ +# Building Continuous Delivery (CD) Pipelines + +## Creating a pipeline job + +1. Have a look at the [repository](https://github.com/bmuschko/todo-spring-boot) `bmuschko/todo-spring-boot` on GitHub. The repository already contains the build definition in the form of a `Jenkinsfile`. Identify each of the steps. +2. In Jenkins, set up the credentials `SONARCLOUD_TOKEN` and `HEROKU_API_KEY` if they don't exist yet. +3. Create a new multi-branch pipeline job for the repository. +4. The initial build is triggered automatically. Have a look at the pipeline in the standard view and its console output. +5. Install the Blue Ocean plugin. +6. Open the Blue Ocean pipeline visualization for the job. Manually trigger the deployment step. Open a browser with the deployed application on Heroku. +7. Create a new branch named `bugfix` and push it to the remote repository. The code should be based off of `master`. +8. Select "Scan Multibranch Pipeline Now". The job should build the new branch. + +The created credentials required for the job. + +![Credentials](./images/11-pipeline-job/credentials.png) + +Create a new item from the dashboard. + +![Multi-Branch Pipeline Job](./images/11-pipeline-job/multi-branch-pipeline-job.png) + +Point the job to the SCM. + +![Multi-Branch Pipeline Job](./images/11-pipeline-job/job-scm.png) + +Upon pressing the OK button, the job will scan all available branches in the repository. + +```bash +Started +[Thu Jul 18 09:23:53 MDT 2019] Starting branch indexing... + > git --version # timeout=10 + > git ls-remote --symref git@github.com:bmuschko/todo-spring-boot.git # timeout=10 +Creating git repository in /Users/bmuschko/.jenkins/caches/git-a68a5e08a54549aaef01872e9adb6218 + > git init /Users/bmuschko/.jenkins/caches/git-a68a5e08a54549aaef01872e9adb6218 # timeout=10 +Setting origin to git@github.com:bmuschko/todo-spring-boot.git + > git config remote.origin.url git@github.com:bmuschko/todo-spring-boot.git # timeout=10 +Fetching & pruning origin... +Listing remote references... + > git config --get remote.origin.url # timeout=10 + > git --version # timeout=10 + > git ls-remote -h git@github.com:bmuschko/todo-spring-boot.git # timeout=10 +Fetching upstream changes from origin + > git config --get remote.origin.url # timeout=10 + > git fetch --tags --force --progress origin +refs/heads/*:refs/remotes/origin/* --prune +Checking branches... + Checking branch master + ‘Jenkinsfile’ found + Met criteria +Scheduled build for branch: master +Processed 1 branches +[Thu Jul 18 09:23:57 MDT 2019] Finished branch indexing. Indexing took 4 sec +Finished: SUCCESS +``` + +You can see the different stages of the pipeline in the standard view. + +![Standard Pipeline](./images/11-pipeline-job/standard-pipeline.png) + +You can see the different stages of the pipeline in the standard view. + +![Standard Pipeline](./images/11-pipeline-job/standard-pipeline.png) + +To console output allows for triggering or aborting the manual deployment step. + +![Console Manual Step](./images/11-pipeline-job/console-manual-step.png) + +Install the Blue Ocean plugin. + +![Blue Ocean Plugin](./images/11-pipeline-job/blue-ocean-plugin.png) + +The Blue Ocean pipeline view offers a UI element for triggering a manual step. + +![Blue Ocean Manual Step](./images/11-pipeline-job/blue-ocean-manual-step.png) + +Press the button for processing with the manual step. + +![Blue Ocean Triggered Manual Step](./images/11-pipeline-job/triggered-manual-step.png) + +The finished pipeline in Blue Ocean. + +![Blue Ocean Finished Pipeline](./images/11-pipeline-job/finished-build.png) + +Check out the repository and push a new branch. + +```bash +$ git clone git@github.com:bmuschko/todo-spring-boot.git +Cloning into 'todo-spring-boot'... +remote: Enumerating objects: 230, done. +remote: Total 230 (delta 0), reused 0 (delta 0), pack-reused 230 +Receiving objects: 100% (230/230), 108.69 KiB | 452.00 KiB/s, done. +Resolving deltas: 100% (105/105), done. +$ cd todo-spring-boot +$ git branch bugfix +$ git checkout bugfix +Switched to branch 'bugfix' +$ git push origin bugfix +Total 0 (delta 0), reused 0 (delta 0) +remote: +remote: Create a pull request for 'bugfix' on GitHub by visiting: +remote: https://github.com/bmuschko/todo-spring-boot/pull/new/bugfix +remote: +To github.com:bmuschko/todo-spring-boot.git + * [new branch] bugfix -> bugfix +``` + +After scanning the repository, the new branch will be available and was triggered to build automatically. + +![Bugfix Branch](./images/11-pipeline-job/bugfix-branch.png) \ No newline at end of file diff --git a/images/11-pipeline-job/blue-ocean-manual-step.png b/images/11-pipeline-job/blue-ocean-manual-step.png new file mode 100644 index 0000000..62f4192 Binary files /dev/null and b/images/11-pipeline-job/blue-ocean-manual-step.png differ diff --git a/images/11-pipeline-job/blue-ocean-plugin.png b/images/11-pipeline-job/blue-ocean-plugin.png new file mode 100644 index 0000000..1bd4249 Binary files /dev/null and b/images/11-pipeline-job/blue-ocean-plugin.png differ diff --git a/images/11-pipeline-job/bugfix-branch.png b/images/11-pipeline-job/bugfix-branch.png new file mode 100644 index 0000000..83579ce Binary files /dev/null and b/images/11-pipeline-job/bugfix-branch.png differ diff --git a/images/11-pipeline-job/console-manual-step.png b/images/11-pipeline-job/console-manual-step.png new file mode 100644 index 0000000..96be5b2 Binary files /dev/null and b/images/11-pipeline-job/console-manual-step.png differ diff --git a/images/11-pipeline-job/credentials.png b/images/11-pipeline-job/credentials.png new file mode 100644 index 0000000..287c072 Binary files /dev/null and b/images/11-pipeline-job/credentials.png differ diff --git a/images/11-pipeline-job/finished-build.png b/images/11-pipeline-job/finished-build.png new file mode 100644 index 0000000..20b64b5 Binary files /dev/null and b/images/11-pipeline-job/finished-build.png differ diff --git a/images/11-pipeline-job/job-only-master.png b/images/11-pipeline-job/job-only-master.png new file mode 100644 index 0000000..3b9f68e Binary files /dev/null and b/images/11-pipeline-job/job-only-master.png differ diff --git a/images/11-pipeline-job/job-scm.png b/images/11-pipeline-job/job-scm.png new file mode 100644 index 0000000..946dca9 Binary files /dev/null and b/images/11-pipeline-job/job-scm.png differ diff --git a/images/11-pipeline-job/multi-branch-pipeline-job.png b/images/11-pipeline-job/multi-branch-pipeline-job.png new file mode 100644 index 0000000..7c2ab14 Binary files /dev/null and b/images/11-pipeline-job/multi-branch-pipeline-job.png differ diff --git a/images/11-pipeline-job/standard-pipeline.png b/images/11-pipeline-job/standard-pipeline.png new file mode 100644 index 0000000..37518f8 Binary files /dev/null and b/images/11-pipeline-job/standard-pipeline.png differ diff --git a/images/11-pipeline-job/triggered-manual-step.png b/images/11-pipeline-job/triggered-manual-step.png new file mode 100644 index 0000000..4644484 Binary files /dev/null and b/images/11-pipeline-job/triggered-manual-step.png differ