Jenkins 自动化

maven 安装

  • 如何安装: https://www.runoob.com/maven/maven-setup.html

  • 官网: https://maven.apache.org/

  • 历史版本: https://archive.apache.org/dist/maven

wget https://archive.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
tar -xvf  apache-maven-3.6.1-bin.tar.gz -C /usr/local/


cp /etc/profile /etc/profile.bak


cat <<'EOF'>> /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.3.9
export PATH=${PATH}:${MAVEN_HOME}/bin
EOF

node 安装

wget https://nodejs.org/dist/v14.18.3/node-v14.18.3-linux-x64.tar.xz
tar xf  node-v14.18.3-linux-x64.tar.xz -C /usr/local/


cp /etc/profile /etc/profile.bak


cat <<'EOF'>> /etc/profile
export NODE_HOME=/usr/local/node-v14.18.3-linux-x64
export PATH=$PATH:$NODE_HOME/bin
EOF

Java 11

  • 官网: https://www.oracle.com/java/technologies/downloads/#java11

  • 华为镜像站: https://repo.huaweicloud.com/java/jdk/

export JAVA_HOME=/usr/local/jdk
export JRE_HOME=/usr/local/jdk/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

docker-compose

cat docker-compose.yml 
version: '3'
services:
    jenkins:
        image: 'jenkins/jenkins'
        container_name: jenkins
        restart: always
        environment:
                - TZ=Asia/Shanghai
                - MAVEN_HOME=/usr/local/apache-maven-3.6.3
                - NODE_HOME=/data/opt/node-v14.18.3
                - JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
                - ANDROID_SDK_ROOT=/data/opt/android-sdk-linux/
        ports:
                - '8888:8080'
                - '50001:50000'
        volumes:
                - '/etc/localtime:/etc/localtime'
                - '/data/opt/docker-jenkins/profile:/etc/profile'
                - '/etc/java-8-openjdk/:/etc/java-8-openjdk/'
                - '/var/jenkins_home:/var/jenkins_home'
                - '/var/run/docker.sock:/var/run/docker.sock'
                - '/usr/bin/docker:/usr/bin/docker'
                - '/usr/lib/jvm/java-1.8.0-openjdk-amd64:/usr/lib/jvm/java-1.8.0-openjdk-amd64'
                - '/usr/local/apache-maven-3.6.3:/usr/local/apache-maven-3.6.3'
                - '/data/opt/node-v14.18.3:/data/opt/node-v14.18.3'
                - '/data/opt/android-sdk-linux/:/data/opt/android-sdk-linux/'
                - '/etc/ssl/certs/java/cacerts:/etc/ssl/certs/java/cacerts'

gitlab 安装

docker pull gitlab/gitlab-ce

mkdir -p /usr/local/docker/gitlab
cd /usr/local/docker/gitlab
touch install.sh
chmod 777 install.sh
mkdir config
mkdir data
mkdir logs
#!/bin/bash
docker run --detach \
  --publish 10443:443 --publish 8082:80 --publish 1022:22 \
  --name gitlab \
  --restart always \
  --volume /usr/local/docker/gitlab/config:/etc/gitlab \
  --volume /usr/local/docker/gitlab/logs:/var/log/gitlab \
  --volume /usr/local/docker/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest

Last updated