Detailed tutorial on docker-compose deployment and configuration of Jenkins

Detailed tutorial on docker-compose deployment and configuration of Jenkins

Docker-compose deployment configuration jenkins

1. Docker-compose file

version: '3.1'
services:
 Jenkins:
  image: jenkins/jenkins:lts
  volumes:
   - /data/jenkins/:/var/jenkins_home
   - /var/run/docker.sock:/var/run/docker.sock
   - /usr/bin/docker:/usr/bin/docker
   - /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
  ports:
   - "8080:8080"
  expose:
   - "8080"
   - "50000"
  privileged: true
  user: root
  restart: always
  container_name: jenkins
  environment:
   JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'

root@zpl:/opt/jenkins# docker-compose up -d

Then ip+port access

2. Unlock Jenkins

root@zpl:/opt/jenkins# cat /data/jenkins/secrets/initialAdminPassword

Then paste the password into the page

3. Jenkins plugin installation

This step is very slow, please be patient.

Install the plugin:

Required plugins:

• Maven Integration plugin

• Deploy to container Plugin

The following plugins need to be installed:

Install the plugin Deploy to container --- support automated code deployment to the tomcat container

The Git plugin may already be installed

Maven Integration: Jenkins uses Maven to compile and package the required plugins

Publish Over SSH: Connect via SSH

ssh plugin

Installation process:

System Management--->Plugin Management---->Optional Plugins--->Filter Deploy to container---->Check--->Direct Installation

4. Configure ssh

Jenkins home directory

Pull to the bottom

5. Configure jdk, maven commands, and global configuration

6. Build and Release

Calling Maven command

The project address is changed to https://github.com/bingyue/easy-springmvc-maven.git

Deploy Java server and package Jenkins for online use

[root@java-server ~]# mkdir -p /data/application

Upload JDK

[root@java-server ~]# tar xzf jdk-8u191-linux-x64.tar.gz -C /usr/local/

[root@java-server ~]# cd /usr/local/

[root@java-server local]# mv jdk1.8.0_191/java

Download tomcat

[root@java-server ~]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz

[root@java-server ~]# tar xzf apache-tomcat-8.5.42.tar.gz -C /data/application/

[root@java-server ~]# cd /data/application/

[root@java-server application]# mv apache-tomcat-8.5.42/ tomcat

Setting Environment Variables

[root@java-server ~]# vim /etc/profile

export JAVA_HOME=/usr/local/java

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

export TOMCAT_HOME=/data/application/tomcat

[root@java-server ~]# source /etc/profile

test:

[root@java-server ~]# java -version

java version "1.8.0_191"

Java(TM) SE Runtime Environment (build 1.8.0_191-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

Delete the contents of the tomcat default release directory:

[root@java-server ~]# rm -rf /data/application/tomcat/webapps/*

[root@java-server ~]# cd /data/application/tomcat/webapps/

[root@java-server webapps]# ls

Create directories and scripts:

[root@java-server ~]# mkdir /opt/script #Create script directory

[root@java-server ~]# vim app-jenkins.sh #Create script

i[root@java-server ~]# vim app-jenkins.sh

The script content is below

[root@java-server ~]# chmod +x app-jenkins.sh #Add execution permission

[root@java-server ~]# mv app-jenkins.sh /opt/script/

Return to the Jenkins page to start the build task

Log in to the tomcat server for verification

This is the end of this article about the detailed tutorial on how to deploy and configure Jenkins with docker-compose. For more information about deploying Jenkins with docker-compose, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Jenkins configuration automatic email sending process diagram
  • Jenkins configuration python script timing task process diagram
  • How to configure user role permissions in Jenkins
  • How to use Jenkins to configure Git+Maven automated build
  • Jenkins installation and configuration notes
  • Detailed installation and configuration of Jenkins
  • Jenkins primary application Publish Over SSH plugin configuration

<<:  Detailed implementation plan of Vue front-end exporting Excel files

>>:  MySQL database backup and recovery implementation code

Recommend

Implementation of CSS dynamic height transition animation effect

This question originated from a message on Nugget...

Kill a bunch of MySQL databases with just a shell script like this (recommended)

I was woken up by a phone call early in the morni...

The difference between char and varchar in MYSQL

CHAR and VARCHAR types are similar, differing pri...

How to use the concat function in mysql

As shown below: //Query the year and month of the...

How to achieve 3D dynamic text effect with three.js

Preface Hello everyone, this is the CSS wizard - ...

Three ways to implement text color gradient in CSS

In the process of web front-end development, UI d...

About deploying a web project to Alibaba Cloud Server (5 steps to do it)

1. First log in to the Alibaba Cloud website to r...

How to use React slots

Table of contents need Core Idea Two ways to impl...

Solution to the error reported by Mysql systemctl start mysqld

Error message: Job for mysqld.service failed beca...

How to install mysql database in deepin 2014 system

Deepin 2014 download and installation For downloa...

How to modify port 3389 of Windows server 2008 R2 remote desktop

The default port number of the Windows server rem...

Practice of multi-layer nested display of element table

There is a requirement for a list containing mult...

The most detailed method to install docker on CentOS 8

Install Docker on CentOS 8 Official documentation...