jenkins package deployment tool installation

Package download

Configure environment

tar zxf apache-maven-xxxx.tar.gz  -C /usr/local
tar zxf gradle-xxxx.tar.gz -C /usr/local
tar zxf node-xxxxx.tar.gz -C /usr/local
tar zxf apache-ant-xxxx.tar.gz -C /usr/local

#Add environment variable
vim /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.0
export ANT_HOME=/usr/local/apache-ant-1.10.5
export GRADLE_HOME=/usr/local/gradle-5.3
export NODE_HOME=/usr/local/node-v10.15.3-linux-x64
export JAVA_HOME=/usr/local/jdk1.8.0_201
export PATH=$PATH:$JAVA_HOME/bin

# Effective global environment variable
source /etc/profile   

Build tool integration

It should be emphasized here that Jenkins calls these tools through environment variables. There are two ways: one is to add environment variables of building tools in Jenkins system configuration, and the other is to define them directly in Jenkins file. There is no difference in the implementation effect. The latter is more flexible, which is good for configuring Jenkins stateless.

Configuration through Jenkins

We open the system management - > global tool configuration page, which is where we configure the build tools we use in the process of running the pipeline. If you don't find maven, you need to install the plug-in Maven Integration.

Here we define the construction tool by the way of variable name and variable value. The variable name cannot conflict, but can be case. On the value conservative point of variable can be defined as make_ Home / usr / local / apache-maven-3.6.0 /, or absolute path / usr/local/apache-maven-3.6.0/bin/mvn. How can we use the tool in Jenkins file after defining the tool?

Use in Jenkinsfile: as shown in the above figure, the name of maven variable I defined is M3. Next, use tool in Jenkinsfile to get the variable value. As follows:

            def mvnHome = tool 'M3'
            sh "${mvnHome}/bin/mvn  clean package "

Configuration via Jenkinsfile

The definition in Jenkinsfile is the same as that in the above system. We only need to define the variable name and value directly in the file. It is then called directly.

            def mvnHome = '/usr/local/apache-maven-3.6.0'
            sh "${mvnHome}/bin/mvn  clean package "

Now are you clear about the integration of build tools? For example, the current construction tools you use are not in my scope of examples. I believe you know how to integrate through this article. Right: install the build tool in the system and define the environment variables in Jenkins file. Special tools special treatment!

Publishing tool installation

We often use the two tools of saltstack and ansible for publishing tools. Here is how to integrate them.

Install saltstck

saltstack is also a C/S architecture. It needs to install the salt minion client in the application server.

yum source:

yum –y install salt-master salt-minion

service salt-master start
service salt-minion start 

chkconfig salt-master on
chkconfig salt-minion on 

Install ansible

Ansible does not need to install the client. It communicates through SSH protocol. Use the / etc/ansible/hosts file to control the host.

yum install epel-release ansbile
service ansible start 

Publishing tool integration

            sh " salt ${host} "

            sh " ansible -m ping ${host} "

For the time being, you need to read the details of the release tool on your own. saltstack has API services that encapsulate HTTP API s in jenkinsfile.

Tags: Programming Maven Apache jenkins ansible

Posted on Sun, 14 Jun 2020 23:04:48 -0400 by mj99