Home > Mobile >  Jenkins stuck at sh command
Jenkins stuck at sh command

Time:09-01

Here is my script while adding as a pipeline request

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

Here is the jenkins console

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

Edit 2 After using sudo ufw allow 8080 command on my terminal and changed the pipeline code the error remains the same is there anything i can do

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

Edit 3

So here i have solved the problem via removing the path variable from configure system file and it's executing the shell scripts but now my pipeline scripts look like this

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"
            }
            }
    
    }
}

And my error look like this

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

CodePudding user response:

I think flutter --version does an HTTP call to determine whether there are updates available. So this must be taking time, or maybe the request is blocked by your Firewall?

Try executing the below instead.

flutter --version --no-version-check

CodePudding user response:

  /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

This part in your exception from edit3 is actually a part of the answer.
Your Jenkins instance does not have permissions to remove files or directories in that folder.

You could try to change the folder ownership with the command:
sudo chown jenkins:jenkins /pathto/folder

  • Related