Post

Jenkins配置

最近在处理一个海外应用,打包机本来是在上海的,由于一些特殊原因,准备迁移到海外,迁移一下 jenkins 顺便记录下过程

1
2
3
4
5
6
7
8
9
# 前置条件, install jdk-11,这里使用了jenv工具
# https://ostechnix.com/how-to-manage-multiple-java-versions-with-jenv-on-linux/
git clone https://github.com/jenv/jenv.git ~/.jenv
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(jenv init -)"' >> ~/.bashrc
source ~/.bashrc
# after this,you should reset your session.
jenv enable-plugin export
exec $SHELL -l
1
2
3
4
5
# install on centos.
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins

1
2
3
4
sudo vi /etc/systemd/system/jenkins.service
sudo systemctl enable /etc/systemd/system/jenkins.service
sudo systemctl start jenkins
systemctl status jenkins
1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=jenkins service
After=network.target

[Service]
Type=simple
LimitNOFILE=65536
ExecStart=/usr/bin/jenkins
User=work
Environment="JENKINS_PORT=8082"

[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# build android project
wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
unzip commandlinetools-linux-8512546_latest.zip
chmod a+x cmdline-tools/
cd cmdline-tools/bin
./sdkmanager --sdk_root=/home/work/workspace/android_sdk --list
./sdkmanager --install 'platforms;android-33' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'build-tools;33.0.0' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'cmdline-tools;7.0' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'build-tools;32.0.0' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'ndk;25.1.8937393' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'platforms;android-28' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'platforms;android-29' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'platforms;android-30' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'platforms;android-31' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'cmake;3.22.1' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'build-tools;31.0.0' --sdk_root=/home/work/workspace/android_sdk
./sdkmanager --install 'cmake;3.10.2.4988404' --sdk_root=/home/work/workspace/android_sdk
1
2
3
# if ssh key Permissions 0664 for '/home/work/.ssh/jenkins_id_rsa' are too open

chmod 600 ~/.ssh

升级 Jenkins

不同版本阅读官方说明文档https://www.jenkins.io/zh/doc/upgrade-guide/

1
2
3
4
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
This post is licensed under CC BY 4.0 by the author.