WSO2使用Jenkins进行CI/CD
WSO2安装使用的全过程详解: https://blog.csdn.net/weixin_43916074/article/details/127987099.
1. Tool Install
1.0 Port
- 详细资料请看上面的链接
wos2 port:9443
gitlab port:38080
jenkins port:8888
1.1 wso2 Install
- 拉取镜像/版本
docker pull wso2/wso2am
docker pull wso2/wso2am:4.0.0 => 可以指定版本
- 使用root权限创建容器(里面还有jenkins port的映射8888)
Docker run reference: https://docs.docker.com/engine/reference/run/.docker run --privileged=true -u=root -d -p 9443:9443 -p 9763:9763 -p 9999:9999 -p 11111:11111 -p 8280:8280 -p 8243:8243 -p 5672:5672 -p 9711:9711 -p 9611:9611 -p 9099:9099 -p 8888:8080 --name mywso2 wso2/wso2am
- 访问UI
https://xxx.xxx.xxx.xxx:9443
1.2 Tool Install
1.2.1 Install git/vim
- 升级
apt-get -y update
- install git/vim
apt-get install -y git
apt-get install -y vim
1.2.2 Install jdk
- wos2 dockerfile已经装了jdk
- install 1.8 jdk(注意安装目录)
apt-get install -y openjdk-8-jdk
- 好像是修改/etc/profile,就可以覆盖掉dockerfile的配置
自己想用哪个配哪个
1.2.3 Install jenkins
- install jenkins
最新版本Jenkins需要java11,如果你的环境是java8 ,可以选择war包安装apt-get install jenkins
- 要升级(容器使用root权限创建的,不需要sudo)
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | tee /etc/apt/sources.list.d/jenkins.list > /dev/null
apt-get update
apt-get install jenkins
- 安装systemctl
sudo apt-get install -y systemctl
systemctl start jenkins
- 管理员密码
cat /var/lib/jenkins/secrets/initialAdminPassword
- 修改配置后执行
systemctl daemon-reload
- 重启Jenkins
systemctl stop jenkins
systemctl restart jenkins
- 删除Jenkins
apt-get remove jenkins
apt-get remove --auto-remove jenkins
apt-get purge jenkins
apt-get purge --auto-remove jenkins
1.3 Jenkins Install
- 下载jenkins war
Downloading Jenkins: https://www.jenkins.io/download/.
- 复制到容器
mkdir software
容器中创建目录docker cp jenkins.war mywso2:/home/wso2carbon/software
- 顺便把apictl也装了
docker cp apictl-4.0.1-linux-x64.tar.gz mywso2:/home/wso2carbon/software
tar -zxvf apictl-4.0.1-linux-x64.tar.gz
ln -s /home/wso2carbon/software/apictl/apictl /usr/bin/apictl
- 编辑启动文件 =>看dockerfile就懂了
vim jenkins_stare.sh
export JAVA_HOME=/opt/java/openjdk
nohup $JAVA_HOME/bin/java -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -jar /home/wso2carbon/software/jenkins.war 2>&1 &
- 密码
cat /root/.jenkins/secrets/initialAdminPassword
- 登陆(前面创建容器的时候做了映射)
http://xxx.xx.xx.xx:8888
- 再写一个关闭的文件
vim jenkins_stop.sh
#!/bin/bash
PID=$(ps -ef | grep jenkins.war | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
echo Application is already stopped
else
echo kill $PID
kill $PID
fi
2. Jenkins CI/CD
2.1 Setting up the environment
2.1.1 Jenkins config
- 需要的环境
- Install jq
apt-get install -y jq
- 安装插件
Generic Webhook Trigger
- config apictl
2.1.2 Setup repository
- 容器中创建目录
mkdir repository
git init
- 连接仓库
git config --global user.name ‘xxxx’
git config --global user.email ‘xxxx’
git clone http://10.136.217.213:38080/nan/source.git
git clone http://10.136.217.213:38080/nan/deployment.git
- set repository webhook
apt-get install jq
- Install jq
apt-get install jq
2.2 Apictl Command
2.2.1 Setup JFrog Artifactory
2.2.2 Configure Jenkins Jobs
3. Awakening
2.2 Apictl Command
2.2.1 Setup JFrog Artifactory
4. Awakening
在一秒钟内看到本质的人和花半辈子也看不清一件事本质的人,自然是不一样的命运。