当前位置: 首页 > article >正文

jenkins配置前端自动部署

创建凭证(gitee/github/gitlab(用户名+密码))

如果密码错误自动构建会报错:

Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/docs
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
The recommended git tool is: NONE
using credential 55ca1747-69da-4472-9daa-0c5473402583
Cloning the remote Git repository
Cloning repository https://gitee.com/Yang_02/cy-docs.git
 >  init /var/jenkins_home/workspace/docs # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /var/jenkins_home/workspace/docs
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:1079)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:825)
	at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1220)
	at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1310)
	at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1277)
	at hudson.scm.SCM.checkout(SCM.java:540)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1250)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522)
	at hudson.model.Run.execute(Run.java:1833)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:446)
Caused by: hudson.plugins.git.GitException: Error performing git command:  init /var/jenkins_home/workspace/docs
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2864)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2768)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2763)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2052)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:1077)
	... 13 more
Caused by: java.io.IOException: Cannot run program "" (in directory "/var/jenkins_home/workspace/docs"): error=2, No such file or directory
	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
	at hudson.Proc$LocalProc.<init>(Proc.java:252)
	at hudson.Proc$LocalProc.<init>(Proc.java:221)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:994)
	at hudson.Launcher$ProcStarter.start(Launcher.java:506)
	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2841)
	... 17 more
Caused by: java.io.IOException: error=2, No such file or directory
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(Unknown Source)
	at java.base/java.lang.ProcessImpl.start(Unknown Source)
	... 24 more
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE

Plugins下的Available plugins下安装插件

SSH server 、publish Over SSH、SSH Build Agents plugin

ssh server 配置

System 下配置服务器账号密码

Tools下安装Nodejs

新建项目

1.

2.git

3.选择node版本

4.执行 shell

node -v
npm -v
npm config set registry https://registry.npmmirror.com/
npm install
npm run build

5.配置打包后自动部署到服务器位置

成功的控制台输出

Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/docs
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
The recommended git tool is: NONE
using credential e23e4531-3163-44cc-87f3-b9a933cdd047
Cloning the remote Git repository
Cloning repository https://gitee.com/Yang_02/cy-docs.git
 > git init /var/jenkins_home/workspace/docs # timeout=10
Fetching upstream changes from https://gitee.com/Yang_02/cy-docs.git
 > git --version # timeout=10
 > git --version # 'git version 2.39.5'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --force --progress -- https://gitee.com/Yang_02/cy-docs.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://gitee.com/Yang_02/cy-docs.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 561705e099e1804170d0b597418ef66bd6e0828f (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 561705e099e1804170d0b597418ef66bd6e0828f # timeout=10
Commit message: "更新文档"
First time build. Skipping changelog.
Unpacking https://nodejs.org/dist/v23.1.0/node-v23.1.0-linux-x64.tar.gz to /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/v23.1.0 on Jenkins
[docs] $ /bin/sh -xe /tmp/jenkins17827783038979128632.sh
+ node -v
v23.1.0
+ npm -v
10.9.0
+ npm config set registry https://registry.npmmirror.com/
+ npm install
(node:11988) ExperimentalWarning: CommonJS module /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/v23.1.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/v23.1.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

added 123 packages in 4m

40 packages are looking for funding
  run `npm fund` for details
+ npm run build

> build
> vitepress build docs


  [32m[1mvitepress[22m v1.5.0[39m

- building client + server bundles...
[33m
The language 'ba' is not loaded, falling back to 'txt' for syntax highlighting.[39m
[33m
The language 'bas' is not loaded, falling back to 'txt' for syntax highlighting.[39m
[33m
The language 'bas' is not loaded, falling back to 'txt' for syntax highlighting.[39m
[33m
The language 'bas' is not loaded, falling back to 'txt' for syntax highlighting.[39m
[33m
The language 'ba' is not loaded, falling back to 'txt' for syntax highlighting.[39m
[33m
The language 'bas' is not loaded, falling back to 'txt' for syntax highlighting.[39m
[32m✓[0m building client + server bundles...
- rendering pages...
[32m✓[0m rendering pages...
build complete in 5.45s.
SSH: Connecting from host [cba571e6d378]
SSH: Connecting with configuration [我的服务器] ...
SSH: Disconnecting configuration [我的服务器] ...
SSH: Transferred 45 file(s)
Build step 'Send files or execute commands over SSH' changed build result to SUCCESS
Finished: SUCCESS


http://www.kler.cn/a/389558.html

相关文章:

  • 前端神经网络入门(三):深度学习与机器学习的关系、区别及核心理论支撑 - 以Brain.js示例
  • Electron 项目启动外部可执行文件的几种方式
  • flink sql + kafka + mysql 如何构建实时数仓
  • 深度学习代码笔记
  • 2024 kali操作系统安装Docker步骤
  • 【知识科普】SPA单页应用程序介绍
  • MSB8041此项目需要 MFC 库。从 Visual Studio 安装程序(单个组件选项卡)为正在使用的任何工具集和体系结构安装-错误解决
  • 2024 年度分布式电力推进(DEP)系统发展探究
  • VBA08-if语句
  • 互动电影《催眠麦克风》官宣定档2.21预售正式开始
  • Kafka-linux环境部署
  • ssm077铁岭河医院医患管理系统+vue(论文+源码)_kaic
  • http协议与内外网的划分
  • uni-app资源管理与图标使用全解
  • Android 获取 SHA1 值的详细步骤
  • 【系统架构设计师】2024年下半年真题论文: 论面向服务的架构设计(包括解题思路和参考素材)
  • 【Linux探索学习】第十二弹——初识进程:进程的定义、描述和一些简单的相关操作
  • Spring Boot框架:构建符合工程认证的计算机课程
  • AIGC:人工智能生成内容的未来
  • 【C#】C# .NET中的Func、Predicate和Expression详解
  • 脉脉大数据面试题及参考答案(2万字长文)
  • Latex中给公式加边框
  • 「Qt Widget中文示例指南」如何创建一个窗口标志?(一)
  • SCNU习题 总结与复习
  • Sql面试题(一)求排名top10
  • json即json5新特性,idea使用json5,fastjson、gson、jackson对json5支持