1、新建Item,输入名称后选择Freestyle project后点击确定

2、配置项目,自定义工作目录

3、配置源码管理和要摘取的分支

4、构建触发器选择github触发

5、构建选择执行windows命令,之后点击保存

#--disable-gpu,跳过语言设置,如不加此选项构建时会卡在语言设置,--path,指定构建后文件路径
echo "开始构建"
C:\CocosDashboard_1.1.0\resources\.editors\Creator\2.4.6\CocosCreator.exe --disable-gpu --path D:\game\Archery --build "platform=web-mobile;debug=false"
echo "构建完成"
echo "开始上传文件到服务器"
C:\Python38\python.exe ../../unzip.py
echo "文件上传完成"

#!/usr/bin/env python
# -*- coding:utf-8 -*- import os,json
import paramiko,zipfile,tarfile class comupload(object):
def __init__(self, hostname, username='root', port=22):
self.private_key = paramiko.RSAKey.from_private_key_file('C:\\Users\\southpark\\.ssh\\id_rsa')
self.hostname = hostname
self.username = username
self.port = port
self.transport = paramiko.Transport((self.hostname, self.port))
self.transport.connect(username=self.username, pkey=self.private_key)
self.sftp = paramiko.SFTPClient.from_transport(self.transport)
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # 允许连接不存在在know_hosts文件里的主机
self.client.connect(hostname=self.hostname, port=self.port, username=self.username, pkey=self.private_key) def upload(self, local_path, remote_path):
# 将文件上传至服务器
self.sftp.put(local_path, remote_path) def download(self, remotepath, localpath):
# 将文件下载到本地
self.sftp.get(remotepath, localpath) def comand(self, com):
# 执行命令
stdin, stdout, stderr = self.client.exec_command(com)
result = stdout.read().decode()
reserr = stderr.read().decode()
return result, reserr def exec_com(self, com):
# 执行命令,返回命令结果和状态码
self.channel = self.client.get_transport().open_session()
self.channel.exec_command(com)
stdout = self.channel.makefile().read()
stderr = self.channel.makefile_stderr().read()
exit_code = self.channel.recv_exit_status()
self.channel.close()
return stdout, stderr, exit_code def sshclose(self):
# 关闭连接
self.sftp.close()
self.client.close() def zipDir(dirpath,outFullName):
zip=zipfile.ZipFile(outFullName,"w",zipfile.ZIP_DEFLATED)
for path,dirnames,filenames in os.walk(dirpath):
fpath = path.replace(dirpath,'')
for filename in filenames:
print(filename,path,fpath)
zip.write(os.path.join(path,filename),os.path.join(fpath,filename))
zip.close() def compress_file(dirpath,filename,project=None):
cur_path = os.getcwd()
os.chdir(dirpath)
tarfilename=filename+'.tar.gz'
with tarfile.open('../../../tarfile/'+tarfilename,"w") as tar:
for root,dirs,files in os.walk('.'):
for single_file in files:
filepath = os.path.join(root,single_file)
tar.add(filepath)
sshtftp=comupload('172.17.0.2')
filepath='D:\\tarfile\\{}'.format(tarfilename)
if project:
sshtftp.upload(filepath,'/root/3nm-web/site/game/{}/game/{}'.format(project,tarfilename))
sshtftp.comand("cd /root/3nm-web/site/game/{project}/game && tar xf {tarfilename} && rm -fr {tarfilename} {filename} && mv web-mobile {filename}".format(project=project,tarfilename=tarfilename,filename=filename))
else:
sshtftp.upload(filepath,'/root/3nm-web/site/game/publicgame/game/public/{}'.format(tarfilename))
sshtftp.comand("cd /root/3nm-web/site/game/publicgame/game/public && tar xf {tarfilename} && rm -fr {tarfilename} {filename} && mv web-mobile {filename}".format(tarfilename=tarfilename,filename=filename))
sshtftp.sshclose()
os.remove(filepath) if __name__ == '__main__':
cur_path = os.getcwd()
with open("settings/builder.json") as f:
res=json.loads(f.read())
filename=res.get('title')
project=res.get('project')
if project:
compress_file('{}\\build\\'.format(cur_path),filename,project)
else:
compress_file('{}\\build\\'.format(cur_path),filename)

构建完成后上传文件到测试服务器脚本

6、开启github-webhook(点击管理jenkins→配置系统→高级→勾选为github指定另外一个HooK URL)

7、启动ngrok,把forwarding地址填写到github

ngrok http http://172.18.188.8:8080

注意:
     如果卡在([1900] checking language setting...)检查语言设置,请检查jenkins服务登录设置,需要新建一个管理员账号,然后使用新建的管理员账号启动jenkins

参考链接:
       https://ngrok.com/download   #ngrok下载链接
       https://www.cnblogs.com/xiloweiEVE/p/15499112.html
       https://www.cnblogs.com/panda-123/p/14456428.html
       https://www.cnblogs.com/weschen/p/6867885.html
       https://blog.csdn.net/weixin_38320674/article/details/110412976

最新文章

  1. Windows Azure HandBook (8) Azure性能测试(1)
  2. SharePoint 2013 数据库中手动更新用户信息
  3. 解决VMware“该虚拟机似乎正在使用中”问题
  4. discuz 发布分类信息,能不能设置单版块去掉“发帖子”(默认点发帖后为自定义的默认分类信息模版)
  5. PowerDesigner反向生成Mysql数据原型
  6. 欧拉计划 NO05 ps:4题想过,好做,但麻烦,有时间补充,这题也不难!
  7. mysql 变量set
  8. Mac系统杂项 (持续更新)
  9. [LeetCode]题解(python):123-Best Time to Buy and Sell Stock III
  10. js数组操作-数组去重
  11. Maven的声明周期(Lifecycle )和命令(Phase)
  12. C#图解教程
  13. [转帖]windows7/windows NT介绍
  14. 利用twilio进行手机短信验证
  15. 第二章 向量(d5)有序向量:插值查找
  16. 20155333 《网络对抗》 Exp9 Web安全基础
  17. 2017全球GDP总量达74万亿美元 各国占比排行榜
  18. odoo12主题样式模块
  19. ADC内设与外设的区别
  20. 搭建企业级Docker Registry -- Harbor

热门文章

  1. 最新版 IDEA 2022.3.2 最优开发配置
  2. JUC学习笔记
  3. JavaScript类
  4. zookeeper要点总结
  5. JS输出formData的全部值
  6. Tkinter模块的使用【转】
  7. 2022-05-09内部群每日三题-清辉PMP
  8. Django路由重定向
  9. RabbitMQ的使用介绍
  10. T137223 节能主义