Jenkins卡在sh命令中

yvgpqqbh  于 2022-11-02  发布在  Jenkins
关注(0)|答案(2)|浏览(301)

以下是我在添加为管道请求时的脚本

pipeline {
    agent any
    stages {
        stage('Version check') {
          steps {
              sh "flutter --version"
            }
        }
    }

}

这是Jenkins的控制台

Started by user Akshay Gupta
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/FirstPipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Version check)
[Pipeline] sh

编辑2在我的终端上使用sudo ufw allow 8080命令并更改管道代码后,错误仍然相同。我可以做些什么吗

pipeline {
    agent any
    stages {
        stage('Version check') {
          steps {
              sh "flutter --version --no-version-check"
            }
        }
    }

}

[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/FirstPipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Version check)
[Pipeline] sh
process apparently never started in /var/lib/jenkins/workspace/FirstPipeline@tmp/durable-7c931453
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

编辑3

在这里,我通过从configure系统文件中删除path变量解决了这个问题,它正在执行shell脚本,但现在我的管道脚本看起来像这样

pipeline {
    agent any
 environment {
        flutter = "/home/stack/Desktop/developer/flutter/bin/flutter"
    }
    stages {
        stage('GIT PULL') {
          steps {
               git branch: 'main', url: 'https://github.com/AkshayStackSum/demo_flutter_app_to_jenkins.git'

            }

        }

           stage('CLEAN') {
     steps {
                sh "${flutter} clean"
            }
            }

           stage('PUB GET') {
     steps {
                sh "${flutter} pub get"
            }
            }

    }
}

我的错误看起来像这样

Started by user unknown or anonymous
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/MyPipeline
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (GIT PULL)
[Pipeline] git
The recommended git tool is: NONE
No credentials specified
 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/MyPipeline/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/AkshayStackSum/demo_flutter_app_to_jenkins.git # timeout=10
Fetching upstream changes from https://github.com/AkshayStackSum/demo_flutter_app_to_jenkins.git
 > git --version # timeout=10
 > git --version # 'git version 2.25.1'
 > git fetch --tags --force --progress -- https://github.com/AkshayStackSum/demo_flutter_app_to_jenkins.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/main^{commit} # timeout=10
Checking out Revision 3076ef00fb2b7330735759edc957f471a8712117 (refs/remotes/origin/main)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 3076ef00fb2b7330735759edc957f471a8712117 # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D main # timeout=10
 > git checkout -b main 3076ef00fb2b7330735759edc957f471a8712117 # timeout=10
Commit message: "flutter project initiated"
 > git rev-list --no-walk 3076ef00fb2b7330735759edc957f471a8712117 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (CLEAN)
[Pipeline] sh
+ /home/stack/Desktop/developer/flutter/bin/flutter clean
fatal: detected dubious ownership in repository at '/home/stack/Desktop/developer/flutter'
To add an exception for this directory, call:

    git config --global --add safe.directory /home/stack/Desktop/developer/flutter
rm: cannot remove '/home/stack/Desktop/developer/flutter/version': Permission denied
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (PUB GET)
Stage "PUB GET" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

Edit 4因此,经过多次尝试,我在一个git项目中取得了成功,但现在我正在使用另一个repo,它显示了这种错误它在本地工作正常,启动应用程序时没有任何冲突,但它抛出了这种错误我只是在我以前的groovy脚本中更改了git集线器repo。

n":"2.1.3","environment":{"sdk":">=2.0.0-dev.61 <3.0.0"},"dependencies":{"matcher":">=0.12.5 <0.13.0","meta":">=1.0.0 <2.0.0"},"dev_dependencies":{"path":">=1.0.0 <2.0.0","test":">=1.2.0 <2.0.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/2.1.3.tar.gz","archive_sha256":"16169b1cc79f01d9c47fe05b5670b87cbf7f5cfc77757369f245c36a6ae2b290","published":"2020-02-28T22:37:37.337683Z"},{"version":"2.1.4","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"2.1.4","environment":{"sdk":">=2.0.0-dev.61 <3.0.0"},"dependencies":{"matcher":">=0.12.5 <0.13.0","meta":">=1.0.0 <2.0.0"},"dev_dependencies":{"path":">=1.0.0 <2.0.0","test":">=1.2.0 <2.0.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/2.1.4.tar.gz","archive_sha256":"5aebd0ad81fc83c6be79d93ceaa3371d60c1eac06dd34b07c0d06974032edfb3","published":"2020-10-26T21:34:46.463591Z"},{"version":"2.1.4+1","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"2.1.4+1","environment":{"sdk":">=2.0.0-dev.61 <3.0.0"},"dependencies":{"matcher":">=0.12.5 <0.13.0","meta":">=1.0.0 <2.0.0"},"dev_dependencies":{"path":">=1.0.0 <2.0.0","test":">=1.2.0 <2.0.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/2.1.4%2B1.tar.gz","archive_sha256":"be9c6c979a6bf7b8deb3437f3119b13588ff36ce4ff59492b7773e12bdc6bc70","published":"2020-10-26T21:49:20.979008Z"},{"version":"2.1.5","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"2.1.5","environment":{"sdk":">=2.0.0-dev.61 <3.0.0"},"dependencies":{"matcher":">=0.12.5 <0.13.0","meta":">=1.0.0 <2.0.0"},"dev_dependencies":{"path":">=1.0.0 <2.0.0","test":">=1.2.0 <2.0.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/2.1.5.tar.gz","archive_sha256":"e83f7ad1e6375da1400b54eea8793bba804d1731d68c5694490bf9296cd3ca24","published":"2020-11-06T00:38:09.398682Z"},{"version":"3.0.0-nullsafety","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"3.0.0-nullsafety","environment":{"sdk":">=2.10.0 <3.0.0"},"dependencies":{"matcher":"^0.12.10-nullsafety","meta":"^1.3.0-nullsafety"},"dev_dependencies":{"path":"^1.8.0-nullsafety","test":"^1.16.0-nullsafety"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.0-nullsafety.tar.gz","archive_sha256":"467a81931eae537f7ed06d836204b5f2541d4cdd804f30e5def9ebf5930c11eb","published":"2020-11-06T01:14:42.006624Z"},{"version":"3.0.0-nullsafety.1","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"3.0.0-nullsafety.1","environment":{"sdk":">=2.10.0 <3.0.0"},"dependencies":{"matcher":"^0.12.10-nullsafety","meta":"^1.3.0-nullsafety"},"dev_dependencies":{"path":"^1.8.0-nullsafety","test":"^1.16.0-nullsafety"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.0-nullsafety.1.tar.gz","archive_sha256":"430e3eb6e642a790b304a90fb1444330466de9228192729c60739fd30ca96039","published":"2020-11-06T01:32:45.901741Z"},{"version":"3.0.0-nullsafety.2","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"3.0.0-nullsafety.2","environment":{"sdk":">=2.12.0-0 <3.0.0"},"dependencies":{"matcher":"^0.12.10-nullsafety.3","meta":"^1.3.0-nullsafety.6"},"dev_dependencies":{"path":"^1.8.0-nullsafety.3","test":"^1.16.0-nullsafety.8"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.0-nullsafety.2.tar.gz","archive_sha256":"48c610a3ade7bda69efaa5de716943d9902d7571ebb10f4a9c4e0896d25a98b5","published":"2020-11-06T02:09:57.515226Z"},{"version":"3.0.0-nullsafety.3","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","homepage":"https://github.com/google/quiver-dart","version":"3.0.0-nullsafety.3","environment":{"sdk":">=2.12.0-0 <3.0.0"},"dependencies":{"matcher":"^0.12.10-nullsafety.3"},"dev_dependencies":{"path":"^1.8.0-nullsafety.3","test":"^1.16.0-nullsafety.8"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.0-nullsafety.3.tar.gz","archive_sha256":"c30db7270f24a0135d4ae116c41b459e6269922691d810fe21461b495568d2cf","published":"2021-01-15T19:41:37.921126Z"},{"version":"3.0.0","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","repository":"https://github.com/google/quiver-dart","version":"3.0.0","environment":{"sdk":">=2.12.0-0 <3.0.0"},"dependencies":{"matcher":"^0.12.10"},"dev_dependencies":{"path":"^1.8.0","test":"^1.16.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.0.tar.gz","archive_sha256":"ca3ae1a9b6c2a7712f6818c8ce6bbcc6cf999115f4fb51b1fa8b7bfe1037d70e","published":"2021-02-17T18:37:19.196841Z"},{"version":"3.0.1","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","repository":"https://github.com/google/quiver-dart","version":"3.0.1","environment":{"sdk":">=2.12.0-0 <3.0.0"},"dependencies":{"matcher":"^0.12.10"},"dev_dependencies":{"path":"^1.8.0","test":"^1.16.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.1.tar.gz","archive_sha256":"5e592c348a6c528fb8deb7cc7d85a7097ce65bf2349121ad004d1fc5d5905eaa","published":"2021-04-06T16:37:06.849276Z"},{"version":"3.0.1+1","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","repository":"https://github.com/google/quiver-dart","version":"3.0.1+1","environment":{"sdk":">=2.12.0-0 <3.0.0"},"dependencies":{"matcher":"^0.12.10"},"dev_dependencies":{"path":"^1.8.0","test":"^1.16.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.0.1%2B1.tar.gz","archive_sha256":"616b691d1c8f5c53b7b39ce3542f6a25308d7900bf689d0210e72a644a10387e","published":"2021-10-15T05:01:19.034255Z"},{"version":"3.1.0","pubspec":{"name":"quiver","description":"Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.","repository":"https://github.com/google/quiver-dart","version":"3.1.0","environment":{"sdk":">=2.12.0-0 <3.0.0"},"dependencies":{"matcher":"^0.12.10"},"dev_dependencies":{"path":"^1.8.0","test":"^1.16.0"}},"archive_url":"https://pub.dartlang.org/packages/quiver/versions/3.1.0.tar.gz","archive_sha256":"93982981971e812c94d4a6fa3a57b89f9ec12b38b6380cd3c1370c3b01e4580e","published":"2022-05-03T20:32:16.263955Z"}],"_fetchedAt":"2022-09-05T11:11:10.482766"}
SLVR:       fact: no versions of google_sign_in match >5.4.1 <6.0.0
SLVR:       conflict: no versions of google_sign_in match >5.4.1 <6.0.0
SLVR:   derived: not google_sign_in >5.4.1 <6.0.0
SLVR:   conflict: google_sign_in 5.4.1 requires Flutter SDK version >=2.8.0
SLVR:   ! google_sign_in 5.4.1 is partially satisfied by not google_sign_in >5.4.1 <6.0.0
SLVR:   ! which is caused by "no versions of google_sign_in match >5.4.1 <6.0.0"
SLVR:   ! thus: google_sign_in ^5.4.1 is forbidden
SLVR:   ! google_sign_in ^5.4.1 is satisfied by google_sign_in ^5.4.1
SLVR:   ! which is caused by "flutter_boiler_plate depends on google_sign_in ^5.4.1"
SLVR:   ! thus: version solving failed
SLVR: Version solving took 0:00:01.065682 seconds.
    | Tried 1 solutions.
FINE: Resolving dependencies finished (1.1s).
ERR : The current Flutter SDK version is 0.0.0-unknown.
    | 
    | Because google_sign_in 5.4.1 requires Flutter SDK version >=2.8.0 and no versions of google_sign_in match >5.4.1 <6.0.0, google_sign_in ^5.4.1 is forbidden.
    | So, because flutter_boiler_plate depends on google_sign_in ^5.4.1, version solving failed.
FINE: Exception type: SolveFailure
FINE: package:pub/src/solver/version_solver.dart 311:5               VersionSolver._resolveConflict
    | package:pub/src/solver/version_solver.dart 132:27              VersionSolver._propagate
    | package:pub/src/solver/version_solver.dart 96:11               VersionSolver.solve.<fn>
    | ===== asynchronous gap ===========================
    | dart:async                                                     Future.catchError
    | package:pub/src/utils.dart 109:52                              captureErrors.wrappedCallback
    | package:stack_trace                                            Chain.capture
    | package:pub/src/utils.dart 122:11                              captureErrors
    | package:pub/src/command.dart 189:13                            PubCommand.run
    | package:args/command_runner.dart 209:27                        CommandRunner.runCommand
    | package:pub/src/command_runner.dart 176:24                     PubCommandRunner.runCommand
    | package:pub/src/command_runner.dart 161:20                     PubCommandRunner.run
    | package:dartdev/dartdev.dart 45:56                             runDartdev
    | /b/s/w/ir/cache/builder/sdk/pkg/dartdev/bin/dartdev.dart 11:9  main
---- End log transcript ----
pub get failed (1; ---- End log transcript ----)
j13ufse2

j13ufse21#

我想flutter --version会调用HTTP来确定是否有可用的更新。所以这一定需要时间,或者请求被防火墙阻止了?
请尝试执行以下操作。

flutter --version --no-version-check
xt0899hw

xt0899hw2#

+ /home/stack/Desktop/developer/flutter/bin/flutter clean
fatal: detected dubious ownership in repository at '/home/stack/Desktop/developer/flutter'
To add an exception for this directory, call:

    git config --global --add safe.directory /home/stack/Desktop/developer/flutter
rm: cannot remove '/home/stack/Desktop/developer/flutter/version': Permission denied

edit3中异常的这一部分实际上是答案的一个 * 部分 *。
您的Jenkins示例没有删除该文件夹中的文件或目录的权限。
您可以尝试使用以下命令更改文件夹所有权:
sudo chown jenkins:jenkins /pathto/folder

相关问题