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

HTML table tag tutorial (3): width and height attributes WIDTH, HEIGHT

By default, the width and height of the table are...

Some questions about hyperlinks

I am very happy to attend this episode of potato ...

MySQL and sqlyog installation tutorial with pictures and text

1. MySQL 1.1 MySQL installation mysql-5.5.27-winx...

MySQL performance optimization index pushdown

Index condition pushdown (ICP) is introduced in M...

CSS Tutorial: CSS Attribute Media Type

One of the most important features of a style she...

Detailed explanation of the use of React.cloneElement

Table of contents The role of cloneElement Usage ...

Details of Linux file descriptors, file pointers, and inodes

Table of contents Linux--File descriptor, file po...

A friendly alternative to find in Linux (fd command)

The fd command provides a simple and straightforw...

Detailed explanation of Windows time server configuration method

Recently, I found that the company's server t...

Two ways to declare private variables in JavaScript

Preface JavaScript is not like other languages ​​...

IIS7 IIS8 http automatically jumps to HTTPS (port 80 jumps to port 443)

IIS7 needs to confirm whether the "URL REWRI...

How to query a record in Mysql in which page of paging

Preface In practice, we may encounter such a prob...

HTML Tutorial: Collection of commonly used HTML tags (6)

These introduced HTML tags do not necessarily ful...