Skip to content

Jenkins Aide-mémoire

Serveur d'automatisation pour compiler, tester et déployer des logiciels.

01

Pipeline

Déclaratif

Pipeline déclaratif en 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" }
    }
  }
}

Environnement

Variables d'environnement et credentials.

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

Fonctionnalités

When

Exécution conditionnelle des stages.

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

Post

Actions post-build.

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

Parallel

Exécution de stages en parallèle.

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

Was this helpful?