Skip to content

omelkova/ci_workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Workshop

"Continuous Integration with Jenkins and Shippable"

Installation

cd box
vagrant up
  • After installation will be finished open the browser and type http://localhost:7070, you have to see Jenkins start page: Jenkins start
  • In order to get the password log in to the VM and navigate to open mentioned file:
vagrant ssh
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy-paste the password

  • Customize Jenkins: select "Select plugins to install". Make sure to select following plugins:
    • Gradle Plugin
    • JUnit Plugin
    • Bitbucket plugin

press "Install" Plugin installation

  • Create admin user as prompted: Create user
  • Start using Jenkins! Setup is finished!

Create new job

From the main page press create new jobs button. Enter the job's name and select 'Freestyle project'. Press 'OK' create new job Scroll down to the 'Build' section, select 'Execute shell' from dropdown menu. Type in the simple shell command echo Hello world. Press 'Save': setup first build On the main page of our project press 'Build now' button from the left menu: Build now

The build will be scheduled and executed. To see the build result navigate to the 'Build History' on the left menu and click on the blue ball. You will see the console output of the first successful build. console output

Now lets fail our first job. For that go to the main page for the 'first job' project and press 'Configure'. Scroll down to the 'Build' section and change script to the command which does not exist, for example ech Hello world, press "Apply". Run build again by pressing "Build Now" in the "first job" view. The build will fail: build failed

Create a real job

Preparation

To setup build for the Point of sail(POS) app, first, we need to recall how to use gradle. Clone your project to the local machine.

  • If you have any problems with accessing your code or do not have this project for some reason, you can first fork and then clone this Bitbucket repository https://bitbucket.org/omelkova/ci-workshop-pos:
    • Create a bitbucket account if you don't have one yet and log in.
    • Go to the Project
    • Click "Fork"
    • Choose any name
    • Click "Fork repository"

After cloning the project to the local machine, cd to the project directory and run following gradle commands:

./gradlew assemble
./gradlew test

If you have forked the workshop project - one test should fail.

Creating a job for Bitbucket project

Create a new job as before. In the "Source Code Management" section select "Git", enter the URL of your forked project. In the Credentials section click 'Add', add your Bitbucket username and password, click "Add": BB credentials Add created credentials: Add credentials In the 'Build Triggers' section select the 'Build when a change is pushed to BitBucket' option: build when change pushed In the 'Build' section select 'Use Gradle Wrapper' radio button. Also tick "Make gradlew executable". Also setup a test gradle task: gradle conf Press "Save". Go to "Bitbucket job" project and click "Build now". See the console output by selecting "Console Output" in the build view.

Setup webhooks

To be able to run build on every 'git push' we need to get a Jenkins bitbucket-webhook address. To allow Bitbucket to see our Jenkins server we need to make it available in the Internet. For that we will use ngrok utility (https://ngrok.com/)

Setup ngrok

  • Go to ngrok web page
  • Download ngrok for your OS
  • unzip to some location
  • open the Terminal in this location and run:
    ./ngrok http 7070
    

Copy the forwarding URL and !!do not close the console!!: ngrok After your Jenkins server become available in the Internet go to your Bitbucket project settings, Webhooks section in the left menu, press "Add webhook". Give any name to your new webhook, paste ngrok forwarding URl+/bitbucket-hook/, press "Save": bb webhook settings Note that this webhook become invalid once you will close your terminal with ngrok running. Once you push changes to your Bitbucket repository the Jenkins build will be triggered automatically.

Setup Slack status notifier

  • Login to your Slack account(https://slack.com/)
  • Configure the Jenkins integration: https://my.slack.com/services/new/jenkins-ci
  • To install this plugin on your Jenkins server
    • Go to the main Jenkins page
    • Press Manage Jenkins on the left panel
    • Click on Manage Plugins and search for Slack in the Available tab. Click the checkbox and install the plugin. install Slack Notifier
    • After it's installed, click on Manage Jenkins again in the left navigation, and then go to Configure System. Find the Global Slack Notifier Settings section and add the provided values: configure Slack
    • In the project configurations go to the Post-build Actions and add Slack Notifications, choose events you'd like to be notified about. conf Slack

press Save. Now you will receive notifications to the selected slack channel during each build.

Shippable

Installation

  • Sign in to Shippable (http://www.shippable.com/) with your Bitbucket credentials
  • Click on the button on the top-left corner of the page and select your Bibucket name
  • Click on Enable project button
  • Find your project and click on Enable enable shippable

Configuration

  • Add shippable.yml from this tutorial to the root folder of your project
  • git add, commit and push. And that is it. Your project's build will be triggered automatically on Shippable and the build status will be displaied on Bitbucket Build field.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published