Git Product home page Git Product logo

jenkins-pipeline-exercise's Introduction

Coding Assignment

While the purpose is to learn Jenkins, this will be a coding assignment. It is made just to give you some tangible code to work with: Remember, this is not a programming exercise, but a Jenkins one; code is only there so you have something to build :)

This repository comes with a java project from the start, but any language can be used. If you want to, just replace the java code with one of the other languages from (this repository)[https://github.com/emilybache/GildedRose-Refactoring-Kata].

The description of the application can be read here, but is not necessary yet.

0. Fork the repo and clone it down on your machine

And with your machine, we mean your VM.

1. Create a Jenkins server

  • Cd into the repo
  • Checkout the trondheim branch
  • cd into the setup folder.
  • execute the setup.sh

2. Create a job

  • Go into your Jenkins server and click on the New Item button on the left.
  • Name your new job "#team# gilded rose" and choose Pipeline and click OK
  • Head down to the Pipeline section of the job, and click on the "try sample pipeline" and choose Hello world
  • Save and Build it.

The result should very well be that you have a blue (successful) build. Verify in Console that hello world was printed out.

3. Link Jenkins with your repo

  • Click the configure button in the job
  • Scroll to the pipeline section
  • In the definition, select Pipeline script from SCM
  • Add the url to your newly forked repository
  • Set the branch to */trondheim
  • Save
  • Build
  • Expect the unexpected!

4 make Jenkins trigger on changes from github

  • Go to the settings section of your repo

  • Select webhooks

  • Create a new webhook. The url will be /github-webhook/

  • Go to your Jenkins server

  • Configure your job

  • At the trigger section, select GitHub hook trigger for GITScm polling

  • Save

5. make stages

Edit the Jenkinsfile on your newly forked repository (Feel free to clone it to your own machine. This way you can use a proper IDE) Make three stages:

  • Preparation
  • Build
  • Results

each of the states should have part saying echo "stage name"

Find the decalarative syntax here.

Commit and push your changes

Go to the Jenkins server and see if the job was triggered, and all three stages are present in the UI afterwards.

6. Running a Gradle test and archiving

With Preperation now being done, we need to build the code and store the result. For each of the bullit points, try to build it to make sure it works before moving to the next.

  • In your Build stage, execute ./gradlew clean test jar
  • In your Results stage, make jUnit display the results of **/build/test-results/test/TEST-*.xml (lookup jUnit in the pipeline syntax if needed)
  • Also in your Results stage, archive the generated jar file in the build/libs folder

The archiving part can be verified by looking for a small blue arrow next to the build number in the overview. Make sure you get your Jar file with you there.

7. fixing Gilded Rose

Having your pipeline set up, now it is time to fix the software problem itself. Go back to the gilded rose description to read about it

Xtra. Parallel and stashing

We also need to get the javadoc generated for the project.

Fortunately that can be done with a small ./gradlew javadoc command.

  • Create another stage called Javadoc where you execute the above command, and archive the result in the build/docs/javadoc folder.

Now we have two processes that actually can be run in parallel. The build and javadoc steps both take in the sourcecode and produces artifacts. So lets try to run them in parallel.

This assignment is loosely formulated, so you need to look things up yourself in order to complete this one

  • Stash the source code cloned in Preparation and call it source

  • build and javadoc steps needs to be included in a parallel step like the one below

  • Unstash the source code in both stages, and perform the normal build steps

  • Stash the results instead of archiving. Call them jar and javadoc

  • Unstash them in the Results step in the end where you archive them.

jenkins-pipeline-exercise's People

Contributors

naesheim avatar magnusrr avatar sofusalbertsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.