Skip to content

CI/CD

  • CI/CD is a strategy that allows you to automate the code deployment, reducing errors and manual efforts
  • The pipeline is the entire workflow that is executed when going through the CI/CD process
  • Your code must always be versioned!

  • Continuos Integration

  • Merge to mainline frequently (Trunk-based, for example)
  • Avoid merge conflicts by constantly merging
  • Build, package and test automatically (automated pipelines)
  • No additional manual testing is necessary (limited trust in automation)
  • Continuous Delivery
  • Fully automated process until production releases (except the action to promote to production)
  • It's an extension of the continuous integration
  • Deploy to Testing Environment
  • Acceptance Testing
  • Continuous Deployment
  • Same as continuous delivery, but in this case every successful build goes to production
  • No need to promote anything to production. Everything goes to production

Jenkinsfile

  • Jenkins file is pipeline as code

  • Pipeline Syntax

  • Scripted Pipeline
    • Write the whole jenkins configuration with Groovy engine
    • Advanced scripting capabilities and high flexibility
  • Declarative Pipeline
    • Easier to get started, but not that powerful
    • Predefined structure

Steps

  • Test

  • Build the code with the test script

  • E.g., mvn test

  • Test Reports

  • Test reports can be displayed and shown

  • This is configured as a post-build action
  • E.g., test reports under target/surefire-reports/*.xml

  • Compile

  • Jenkins will download the source code

  • If there are changes in the code, it will be builded (compiled)
  • Building tools include maven, npm, etc
  • E.g., -B -DskipTests clean package. The mvn command must be omitted
  • The compile uses the code from the current workspace
  • The resulting .jar is saved on the target folder

  • Archive Artifact

  • Artifact is the result of the build

  • Jenkins can archive this artifact to an artifact registry
  • target/*.jar
  • By default, artifacts are archived in the own workspace
  • Ideally it must be pushed at a separate artifact hub

  • Deploy

  • After compiling and testing the code, the code must be deployed

  • For that, add a new build step to deploy the code
  • Jars can be deployed via shell script java -jar $WORKSPACE/target/my-app-1.0-SNAPSHOT.jar