...
/Exploring the Basic Pull Request Process Through ChatOps
Exploring the Basic Pull Request Process Through ChatOps
This lesson explores the step by step lifecycle of a pull request through the perspective of ChatOps.
We'll cover the following...
The best way to explore the integration Jenkins X provides between Git, Prow, and the rest of the system is through practical examples. The first thing we’ll need is a project, so we’ll create a new one.
Creating a new project
⚠️ Make sure that you are not inside an existing repository before executing the command that follows.
jx create quickstart \--filter golang-http \--project-name jx-prow \--batch-modecd jx-prowjx get activities \--filter jx-prow --watch
We created a Go-based project called jx-prow
, entered the local copy of the Git repository jx
created for us, and started watching the activity. After a while, the steps in the output will be in the Succeeded
status, and we can stop the watcher by pressing ctrl+c.
Creating a pull request
Since most of the ChatOps features apply to pull requests, we need to create one.
git checkout -b chat-opsecho "ChatOps" | tee README.mdgit add .git commit \--message "My first PR with prow"git push --set-upstream origin chat-ops
We created a new branch chat-ops
, we made a silly change to README.md
, and we pushed the commit.
Now that we have the branch with the change to the source code, we should create a pull request. We could do that by going to GitHub UI but, as you already know from the Creating Pull Requests lesson, jx
already allows us to do that through the command line. Given that I prefer the terminal screen over UIs (and you don’t have a say in that matter), we’ll go with the latter option.
jx create pullrequest \--title "PR with prow" \--body "What I can say?" \--batch-mode
We created a pull request and are presented with a confirmation message with a link. Please open it in your favorite browser.
Inspecting the automatically created comment and checks
You will notice a few things right away. A comment was created describing the process we should follow with pull requests. In a nutshell, the PR needs to be approved. Someone should review the changes we are proposing. That might mean going through the code, performing additional manual tests, or anything else that the approver might think is needed before they give their OK.
Near the bottom, you’ll see that a few checks are running.
serverless-jenkins
The serverless-jenkins process is executing the part of the pipeline dedicated to pull requests. At the end of the process, the application will be deployed to a temporary PR-specific environment. This is all the same as before; however, there is an important aspect of PR that we haven’t explored yet. There are rules that we need to follow before we merge to the master and the communication happening between Git and Prow.
tide
The second activity is called tide. It will be in the pending state until we complete the process described in the comment.
Tide is one of the Prow components. It is in charge of merging the pull request to the master branch, and it is configured to do so only after we send it the /approve
command. Alternatively, Tide might close the pull request if it receives /approve cancel
. We’ll explore both soon.
Next, we’ll wait until the Jenkins X build initiated by the creation of the PR is finished. Once it’s done, you’ll see a comment stating ...