我正在部署我的reactjs应用程序。我已经为它编写了管道脚本,以部署在来自Jenkins的EC2服务器上。
每次构建都成功,但没有输出。我无法找到错误。当我通过putty登录到EC2示例时,当我手动部署应用程序时,应用程序正在运行,但当我在管道中编写和执行相同的步骤时,没有输出
我用了好几种方法检查,但都没用
这是我在直接部署到服务器时使用的简单Jenkins文件,因为我正在检查错误
pipeline {
agent {
label 'master'
}
stages {
stage('Deploy') {
agent {
label 'testnode'
}
steps {
script{
sh """
#!/bin/bash
ls
sudo npm start &
"""
}
}
}
}
}
控制台输出
Started by user Mani
Replayed #18
> git rev-parse --resolve-git-dir /var/lib/jenkins/caches/git-02fb4007d201f8b81dff24c4385bb601/.git # timeout=10
Setting origin to https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git
> git config remote.origin.url https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git --version # timeout=10
> git --version # 'git version 2.32.0'
> git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials Bitbucket
> git fetch --tags --force --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
Seen branch in repository origin/master
Seen 1 remote branch
Obtained Jenkinsfile from 95b8c92cd4dab7a9e6e8d13c81c84bca700dbe36
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/React_master
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: git
using credential Bitbucket
> git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/React_master/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git # timeout=10
Fetching without tags
Fetching upstream changes from https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git
> git --version # timeout=10
> git --version # 'git version 2.32.0'
using GIT_ASKPASS to set credentials Bitbucket
> git fetch --no-tags --force --progress -- https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Checking out Revision 95b8c92cd4dab7a9e6e8d13c81c84bca700dbe36 (master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 95b8c92cd4dab7a9e6e8d13c81c84bca700dbe36 # timeout=10
Commit message: "Jenkinsfile edited online with Bitbucket"
> git rev-list --no-walk 95b8c92cd4dab7a9e6e8d13c81c84bca700dbe36 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Deploy)
[Pipeline] node
Running on testnode in /home/ec2-user/workspace/React_master
[Pipeline] {
[Pipeline] checkout
The recommended git tool is: git
using credential Bitbucket
Fetching changes from the remote Git repository
Fetching without tags
> git rev-parse --resolve-git-dir /home/ec2-user/workspace/React_master/.git # timeout=10
> git config remote.origin.url https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git # timeout=10
Fetching upstream changes from https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git
> git --version # timeout=10
> git --version # 'git version 2.32.0'
using GIT_ASKPASS to set credentials Bitbucket
> git fetch --no-tags --force --progress -- https://ManiGopal27@bitbucket.org/nariyapratik/econote-web.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Checking out Revision 95b8c92cd4dab7a9e6e8d13c81c84bca700dbe36 (master)
Commit message: "Jenkinsfile edited online with Bitbucket"
[Pipeline] withEnv
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ ls
Jenkinsfile
node_modules
package.json
package-lock.json
public
README.md
serve.json
src
webpack.config.js
yarn.lock
+ sudo npm start
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
total 39416
drwxrwxrwx 6 ec2-user ec2-user 265 Jun 21 05:19 .
drwxrwxr-x 6 ec2-user ec2-user 100 Jun 20 09:19 ..
-rw-rw-r-- 1 ec2-user ec2-user 25 Jun 21 05:14 .env
drwxrwxrwx 8 ec2-user ec2-user 162 Jun 21 05:20 .git
-rw-rw-r-- 1 ec2-user ec2-user 503 Jun 21 05:14 .gitignore
-rw-rw-r-- 1 ec2-user ec2-user 797 Jun 21 05:14 Jenkinsfile
drwxrwxrwx 1280 ec2-user ec2-user 40960 Jun 15 17:58 node_modules
-rw-rw-r-- 1 ec2-user ec2-user 3429 Jun 21 05:14 package.json
-rw-rw-r-- 1 ec2-user ec2-user 1070508 Jun 21 05:14 package-lock.json
drwxrwxrwx 4 ec2-user ec2-user 105 Jun 21 05:14 public
-rw-rw-r-- 1 ec2-user ec2-user 4397 Jun 21 05:14 README.md
-rw-rw-r-- 1 ec2-user ec2-user 285 Jun 21 05:14 serve.json
drwxrwxrwx 5 ec2-user ec2-user 101 Jun 21 05:14 src
-rw-rw-r-- 1 ec2-user ec2-user 1784 Jun 21 05:14 webpack.config.js
-rwxrwxrwx 1 root root 653925 Jun 15 17:56 yarn.lock
+ sudo npm start
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
当我通过登录到EC2服务器手动使用相同的命令(sudo npm run start)部署应用程序时,它正在运行,我看到了输出,但从Jenkins那里我遇到了这个问题。
有谁能帮我解决这个问题吗?
1条答案
按热度按时间91zkwejq1#
在
jenkins
管道中,始终执行带有“run”的npm
命令