本文主要是介绍ngrok实现内网穿透,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在使用jenkins进行自动化部署时,需要设置github的webhook钩子来触发构建,由于jenkins运行在自己的电脑上,因此需要通过内网穿透来接受http请求。
Install ngrok via Homebrew with the following command:
brew install ngrok/ngrok/ngrok
Put your app online at ephemeral domain Forwarding to your upstream service. For example, if it is listening on port http://localhost:8080, run:
ngrok http http://localhost:8080
ngrok tunnel --label edge=edghts_token http://localhost:8080
将端口映射到本地8080,此时访问ngrok提供的domain,可以访问到本地的jenkins服务。
ngrok tunnel --label edge=edghts_http://localhost:8080
开启管道后使用github测试。注意在提供给我们的地址后面加上:/github-webhook/
发送成功。
在这里插入图片描述
勾选jenkins项目触发器中的GitHub hook trigger for GITScm polling
提交一次推送,此时自动开始构建。
这篇关于ngrok实现内网穿透的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!