Skip to content

Jenkins Spickzettel

Automatisierungsserver zum Bauen, Testen und Ausliefern von Software.

01

Pipeline

Declarative

Declarative Pipeline im Groovy-DSL.

jenkins
pipeline {
  agent any
  stages {
    stage("Build") {
      steps { sh "npm run build" }
    }
    stage("Test") {
      steps { sh "npm test" }
    }
    stage("Deploy") {
      steps { sh "deploy.sh" }
    }
  }
}

Environment

Umgebungsvariablen und Credentials.

jenkins
pipeline {
  environment {
    NODE_ENV = "production"
    API_KEY = credentials("api-key")
  }
}
02

Funktionen

when

Bedingte Ausführung von Stages.

jenkins
stage("Deploy") {
  when { branch "main" }
  steps { sh "deploy.sh" }
}

post

Aktionen nach dem Build.

jenkins
post {
  success { echo "Build passed" }
  failure { emailext to: "[email protected]", subject: "Build failed" }
  always { archiveArtifacts "dist/**" }
}

parallel

Parallele Ausführung von Stages.

jenkins
stages {
  stage("Test") {
    parallel {
      stage("Unit") { steps { sh "npm run test:unit" } }
      stage("E2E") { steps { sh "npm run test:e2e" } }
    }
  }
}

Was this helpful?