最近这一段时间一直使用的是GitHub+Actions实现双部署。因为已经了解到了coding是有访问认证的。但一直忽略了GitHub可以直接使用Token进行访问认证。
https://你的token@github.com/owner/repo.git
deploy:
- type: git
repository:
github: https://你的token@github.com/owner/repo
coding: https://username:password@e.coding.net/owner/repo
branch: master
其中baidu_url_submitter
与baidu_xz_url_submitter
是我安装的百度推送插件。如果你没有安装不必填写。
coding的username
与password
并非你的登录账户,而是访问令牌的账户和密码
pipeline {
agent {
label 'node-10'
}
stages {
stage('克隆项目') {
steps {
sh 'git clone https://账号:密码@地址 .'
sh 'ls -a'
}
}
stage('安装依赖') {
steps {
sh 'ls -a'
sh 'npm install -g hexo-cli'
sh 'npm install hexo --save'
}
}
stage('构建发布') {
steps {
sh 'hexo clean && hexo g && hexo d'
}
}
}
}
1. 脚本会告诉coding的服务器:“我要使用node-10的环境”
2. 执行步骤-克隆项目
- 运行命令`git clone 项目地址` 既然是要对你的文件进行生成,那么这里肯定填的是你源文件的地址,而不是发布的仓库地址。
3. 执行步骤-安装依赖 此步骤模拟你在自己电脑上初次运行hexo时需要做的
4. 执行步骤-构建发布 这一步就相当于你运行
当然了,这一切都是在coding的服务上运行的,所以你只管push,coding服务器会帮你完成这些操作。
然后替换博客根目录下 配置文件中的git地址。
同样的地址也是https://username:password@项目地址
假如说我的
- 令牌用户名是:`root`令牌密码是:
- 项目地址是`https://e.coding.net/test/test.git`
那么在配置文件中的地址就是https://root:abcdefg@e.coding.net/test/test.git
12345abc
我的项目地址为https://github.com/test/test.git
那么配置文件(hexo的配置文件)中的deploy地址就应该为https://12345abc@github.com/test/test.git
最后,如果我的文章对你有帮助,那么你可以点下边的赞赏按钮,请作者喝杯咖啡哦!
如果图片失效请在下方留言,或联系作者。
原创不易,所有文字及图片都是我自己一个一个弄得。搬砖党请尊重一下作者,转载请标明出处。