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

Linux uses join -a1 to merge two files

To merge the following two files, merge them toge...

Detailed steps for manually configuring the IP address in Linux

Table of contents 1. Enter the network card confi...

Detailed explanation of how to access MySQL database remotely through Workbench

Preface Workbench is installed on one computer, a...

Ubuntu 16.04 kernel upgrade steps

1. Environment Ubuntu 16.04 running on a virtual ...

How to set up cross-domain access in IIS web.config

Requirement: The page needs to display an image, ...

HTML head tag detailed introduction

There are many tags and elements in the HTML head ...

Detailed steps to store emoji expressions in MySQL

Caused by: java.sql.SQLException: Incorrect strin...

Three ways to refresh iframe

Copy code The code is as follows: <iframe src=...

Use pure CSS to achieve switch effect

First is the idea We use the <input type="...

Introduction to Linux File Compression and Packaging

1. Introduction to compression and packaging Comm...

HTML+CSS div solution when relative width and absolute width conflict

Div solution when relative width and absolute wid...

WeChat applet implements form verification

WeChat applet form validation, for your reference...

Vue + element to dynamically display background data to options

need: Implement dynamic display of option values ...

This article teaches you how to import CSS like JS modules

Table of contents Preface What are constructible ...