#Jenkins

The original CI/CD server with powerful extensibility.


#Installation

bash
1# Docker
2docker run -d -p 8080:8080 -p 50000:50000 \
3  -v jenkins_home:/var/jenkins_home \
4  jenkins/jenkins:lts
5
6# Get initial password
7docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

#Jenkinsfile (Declarative)

groovy
1pipeline {
2    agent any
3    
4    environment {
5        DOCKER_IMAGE = 'myapp'
6    }
7    
8    stages {
9        stage('Build') {
10            steps {
11                sh 'npm ci'
12                sh 'npm run build'
13            }
14        }
15        
16        stage('Test') {
17            steps {
18                sh 'npm test'
19            }
20        }
21        
22        stage('Docker Build') {
23            steps {
24                sh "docker build -t ${DOCKER_IMAGE}:${BUILD_NUMBER} ."
25            }
26        }
27        
28        stage('Deploy') {
29            when {
30                branch 'main'
31            }
32            steps {
33                sh 'echo Deploying...'
34            }
35        }
36    }
37    
38    post {
39        always {
40            cleanWs()
41        }
42        failure {
43            mail to: 'team@example.com',
44                 subject: "Failed: ${env.JOB_NAME}",
45                 body: "Build failed"
46        }
47    }
48}

#Key Plugins

PluginPurpose
PipelineDeclarative pipelines
GitGit integration
DockerDocker support
Blue OceanModern UI
CredentialsSecret management

[!TIP] Pro Tip: Use declarative pipelines for maintainability!