詹金斯(Jenkins Build)说成功,但看不到输出?

发布于 2025-02-09 08:44:01 字数 6876 浏览 1 评论 0原文

我正在部署我的ReactJS应用程序。为此,我编写了管道脚本以从Jenkins部署在EC2服务器上。

每次构建都是成功的,但没有输出。我找不到错误。 当我通过PUTTY登录到EC2实例,而当我手动部署应用程序时,应用程序正在运行,但是当我写入管道和执行时,输出不会进行相同的步骤,然后输出不进行,

我已经以多种方式进行了检查,但没有使用,

这是简单的Jenkins文件我正在使用直接部署到服务器时使用,因为当我使用同一命令(sudo npm运行启动)部署应用程序时,我正在检查错误

pipeline {
    agent {
        label 'master'
    }
    stages {
        stage('Deploy') { 
            agent {
                label 'testnode'
            }
            steps {
               script{
                    
                    sh """
                        #!/bin/bash
                        ls
                        sudo npm start &
                    """
                    
                }
            }
        }
    }
}

console upputs

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://[email protected]/nariyapratik/econote-web.git
 > git config remote.origin.url https://[email protected]/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://[email protected]/nariyapratik/econote-web.git # timeout=10
Fetching without tags
Fetching upstream changes from https://[email protected]/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://[email protected]/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://[email protected]/nariyapratik/econote-web.git # timeout=10
Fetching upstream changes from https://[email protected]/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://[email protected]/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服务器,然后是跑步,我正在看到输出,但是从詹金斯(Jenkins)我面临这个问题。

任何人都可以帮助如何解决这个问题吗?

I am deploying my reactjs application. For which I have written pipeline script to deploy on EC2 Server from Jenkins.

Every time build is successful but no output is coming. I am unable to find the error.
When I login to EC2 instance through putty and when i am deploying the application manually then application is running but same steps when i written in pipeline and executing then output is not coming

I have checked in several ways but no use

This is the simple Jenkins file I am using as I am directly deploying in to server because i am checking the error

pipeline {
    agent {
        label 'master'
    }
    stages {
        stage('Deploy') { 
            agent {
                label 'testnode'
            }
            steps {
               script{
                    
                    sh """
                        #!/bin/bash
                        ls
                        sudo npm start &
                    """
                    
                }
            }
        }
    }
}

Console Output

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://[email protected]/nariyapratik/econote-web.git
 > git config remote.origin.url https://[email protected]/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://[email protected]/nariyapratik/econote-web.git # timeout=10
Fetching without tags
Fetching upstream changes from https://[email protected]/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://[email protected]/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://[email protected]/nariyapratik/econote-web.git # timeout=10
Fetching upstream changes from https://[email protected]/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://[email protected]/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

When i deploy the application with same command (sudo npm run start) manually by logging in to EC2 server then it is running and i am seeing the output but from Jenkins i am facing this problem.

Can anyone please help how to solve this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然#的苍凉 2025-02-16 08:44:01

jenkins管道中始终执行npm命令“运行”

ex - npm run start / npm run test / npm run lint

Inside the jenkins pipeline always execute npm commands with "run"

ex - npm run start / npm run test / npm run lint
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文