Skip to content

Instantly share code, notes, and snippets.

@michal-lipski
Last active August 7, 2017 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michal-lipski/8b974639fc2cbb5f3ff189d773747054 to your computer and use it in GitHub Desktop.
Save michal-lipski/8b974639fc2cbb5f3ff189d773747054 to your computer and use it in GitHub Desktop.

Exercise 1. Download and install Jenkins

  1. Go to https://jenkins.io

  2. Download war file

  3. Run using java from Terminal java -jar jenkins.war

  4. Go to http://localhost:8080

  5. Customize with default plugins

  6. Cretate first Admin user

    username: student
    password: student
    e-mail: email@domain.com

  7. Start using jenkins!

Good to know

There is jenkins.war already downloaded in ~/jenkins folder

After installation, Jenkins home folder is located under .jenkins in Your home folder

There is a copy of jenkins home folder with plugins downloaded in ~/backups/1_with_plugins

You can try to run jenkins in docker using command:
sudo docker run -p 8090:8090 -p 50000:50000 jenkins/jenkins:lts

Exercise 2. Manage security

  1. Allow to access jenkins without authentication in read only mode
  2. Log out and see read only mode

Ecercise 4. Automated build

  1. Create Freestyle job that will get the source code from git repository and package the application using maven
  2. Configure job to save build artifact (jar file) after each build

If You fall behind You can always load exercise solution Job from ~/backup folder. Remeber to do "Reload configuration from disc" after You manually add jobs in jenkins directory

Exercise 5. Integrating build.

  1. Configure build to run each time code on repository changes
  2. Configure build to send email each time build fails. Remeber to configure e-mail server in Manage Jenkins -> Configure System -> E-mail notification.
  3. Configure build to show test reports.

Run mailhog email server https://hub.docker.com/r/mailhog/mailhog/ via docker:
sudo docker run --restart unless-stopped --name mailhog -p 1025:1025 -p 8025:8025 -d mailhog/mailhog

JUnit test reports are stored in /target/surefire-reports/

Exercise 6. Plugins.

  1. Install "HTML Publisher" plugin
  2. Configure Job to publish test coverage results as html

Jacoco code coverage reports can be fond under target/site/jacoco

Exercise 7. Pipelines style.

  1. Create new pipeline job
  2. Configure stage to fetch source from github repository
  3. Configure stage to build using mvn without tests (mvn compile)
  4. Configure stage to build only unit tests (mvn surefire:test)
  5. Configure stage to build only integration tests (mvn failsafe:integration-test)

Additional:

  1. Create new pipeline job from JenkinsFile that is stored on repository

You can use Snippet Generator on Pipeline Syntax page

Check pipeline declarative synax: https://jenkins.io/doc/book/pipeline/syntax/

Pipeline steps https://jenkins.io/doc/pipeline/steps/

Exercise 8. Parallel build.

  1. Configure pipeline job from Excercise 7 to run in parallel.
  2. Make "Unit tests" nad "Integration tests" stages run in parallel using pipeline commad: "parallel"
  3. Add new stage at the end that will run 'mvn package'
  4. Run job and see how many executor are used.
  5. Change executors number in Jenkins to 4.
  6. Run job again and see how executors are used - check if job is running faster.

You can change number of executors in Manage Jenkins > Manage Nodes You can use stash and unstash to make build artifact avaliable between nodes execution

@wyhasany
Copy link

Excercise 8 has an error in title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment