文章来自:http://blog.csdn.net/intbird 转载请说明出处
一般情况下 公司内网 git + maven + jenkins 是同一网域公开访问的
但也有例外:
比如公司没有提供***账号供外网访问, 则在家无法访问公司内网资源
如果自己在家的电脑配置够强悍,也可以远程运行服务(如jenkins)
但git中的maven仓库为公司私有网络外网无法访问,
所以有了这篇文章, 主要是内网穿透
的使用(socks代理)
注意:
公司内网穿透的风险是 会暴露公司内网服务,请严格遵守公司制度
firewall-cmd --add-port=8080/tcp --permanent
systemctl stop firewalld
systemctl disable firewalld.service
官网文档
yum install java
curl http://*****.jenkins.war --output jenkins.war
nohup java -jar jenkins.war --httpPort=8080 >jenkins.log 2>&1 &
官网文档
#安装jenkins
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
sudo yum upgrade
sudo yum install jenkins java-1.8.0-openjdk-devel
#启动jenkins
sudo systemctl start jenkins
http://webhooks.ddns.net:8080/
vi /var/lib/jenkins/secrets/initialAdminPassword
用于外部授权触发Jenkins任务(如gitlab等)
Jenkins user token = Jenkins → 用户 → 设置 → API Token → copy only once text
Git + JDK + Gradle + GitLab Plugin+ GitLab Hook Plugin…
Jenkins → 系统管理 → 全局工具配置 → Git + JDK + Gradle + Maven
Jenkins → 系统管理 → 插件管理 → 可选插件 → 搜索: gitlab → 安装重启
Jenkins → 系统管理 → 系统配置 → GitLab → enable auth project → Credentials=${GitLab API token}
Credentials
${GitLab API token} = GitLab → User → Access Tokens → add User Token → Copy only once text → Test Conn…
linux下载安装android sdk
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
mkdir -p /var/lib/jenkins/sdks/andorid/sdk/cmdline-tools
unzip commandlinetools-linux-6609375_latest.zip -d /var/lib/jenkins/sdks/andorid/sdk/cmdline-tools
/var/lib/jenkins/sdks/andorid/sdk/cmdline-tools/tools/bin/sdkmanager --licenses
ln -s /var/lib/jenkins/sdks/andorid/sdk ~/
sudo chmod -R 777 /var/lib/jenkins/sdks/andorid/sdk
配置jenkins环境变量
Jenkins → 系统管理 → 配置 → 全局属性 → 环境变量 → ${key,value}
如果没有sdk配置, 打包会提示: SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project’s local properties file at ‘/var/lib/jenkins/workspace/Android/local.properties’.
gradle依赖会自动安装
新建任务 → 自由风格的软件项目 → GitLab → 源码管理 -> repo (*.git)+ ${ ssh user & pwd}
${GitLab ssh user} = GitLab → User → SSH Keys → Add an SSH key → private key text
勾选: Build when a change is pushed to GitLab: ${Webhooks url } + XX Events …
构建: 执行shell → ./gradlew :app:assembleDebug
构建: gradle build | assembleDebug
构建后通知: publish build status to gitlab
Jenkins user token = Jenkins → 用户 → 设置 → API Token → copy only once text
GitLab → Pick One Project → Settings → Intergrations → ${Webhooks url}
${Webhooks url } = http://JenkinsUser:JenkinsUserToken@JenkinsIPAddress/project/projectName
Test Push ….
内网穿透工具FRP
sudo nohup ./frps -c ./frps.ini >frp_log.log 2>&1 &
[root@intbird ~]# ps -aux | grep frp
root 1335 0.0 0.0 137212 7808 ? S Aug10 0:00 sudo nohup ./frps -c ./frps.ini
root 1337 0.0 0.3 716576 24788 ? Sl Aug10 0:14 ./frps -c ./frps.ini
root 6078 0.0 0.0 12108 1096 pts/2 S+ 05:36 0:00 grep --color=auto frp
frps.ini
[common]
authentication_method = token
section = ***
bind_port = 7000
vhost_http_port = 7070
bind_udp_port = 7001
dashboard_port = 7500
dashboard_user = intbird
dashboard_pwd = ***
[1]+ Running nohup ./frpc -c ./frpc.ini > frp_log.log 2>&1 &
frpc.ini
[common]
authentication_method = token
section = xxx
server_addr = webhooks.ddns.net
server_port = 7000
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = intbird
admin_pwd = xxx
[web]
type = http
local_port = 80
custom_domains = webhooks.ddns.net
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
use_encryption = true
use_compression = true
[plugin_socks5]
type = tcp
remote_port = 8000
plugin = socks5
plugin_user = intbird
plugin_passwd = xxx
[plugin_http_proxy]
type = tcp
remote_port = 8001
plugin = http_proxy
plugin_http_user = intbird
plugin_http_passwd = xxx
frpc admin ui : 127.0.0.1:7400
open http://webhooks.ddns.net:7070/
说明文档
export http_proxy=http://intbird:*****@webhooks.ddns.net:8001
socks5代理url: socks://*******#webhook
官网文档
不要``不要``不要
勾选 Force GRADLE_USER_HOME to use workspace
不够选,则会启用 如图所示的.gradle代理配置,这样不污染git代码
systemProp.http.proxyHost=webhooks.ddns.net
systemProp.http.proxyPort=8001
systemProp.http.proxyUser=intbird
systemProp.http.proxyPassword=xxx
systemProp.http.nonProxyHosts=*.aliyun.com|localhost
官方文档
org.gradle.jvmargs=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1080
end…
文章来自:http://blog.csdn.net/intbird 转载请说明出处