Verify the Software via Jenkins Pipeline - jenkins

stage('Verfiy Software') {
dir('sudo /opt/tomcat/apache/bin/') {
sh './version.sh'
I am running tomcat in Ubuntu box, and its installed following path location /opt/tomcat/apache/.
I have created pipeline script to verify tomcat version and i am referring bin location to get the tomcat version, but unfortunately i am getting below error message.
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Verfiy Software)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/project/sudo /opt/tomcat/apache/bin/version.sh
[Pipeline] {
[Pipeline] sh
+ ./version.sh
/var/lib/jenkins/workspace/project/sudo /opt/tomcat/apache/bin/version.sh#tmp/durable-5c73b35b/script.sh: 1: /var/lib/jenkins/workspace/project/sudo /opt/tomcat/apache/bin/version.sh#tmp/durable-5c73b35b/script.sh: ./version.sh: not found
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
can you please help me on this.

You need sudo only to run version.sh.
stage('Verfiy Software') {
sh 'sudo /opt/tomcat/apache/bin/version.sh'

Related

Getting error "Stage <repoName> skipped due to earlier failure(s)"

Description:In production when was running a jenkins pipeline with set of few jobs it was failing at 2nd stage with above error.
The task of this job is to create a github repository.
Kindly assist.
Resolution:
At the stage where job was failing it was prompting a form or run time prompt to enter the data which was not filled by the user so it was failing with this error.
Upon executing jobs at console it produces something like:
> git checkout -f 4dfa1dc42ea3727a972a81aead8129ab65564208
> git rev-list --no-walk 4dfa1dc42ea3727a972a81aead8129ab65564208 # timeout=10 [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Collecting Infrastructure details) [Pipeline] container [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] sh
+ git --version git version 2.1.4 [Pipeline] input Input requested Approved by Pankaj Gupta (CompuCom) [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // container [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Collecting ServiceNow details) [Pipeline] container [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] input Input requested [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // container [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Display Setup) Stage "Display Setup" skipped due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Validate Inputs) Stage "Validate Inputs" skipped due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Create Repo And Add Collaborators) Stage "Create Repo And Add Collaborators" skipped due to earlier failure(s) [Pipeline] }
So if you look at the output then there are two time a URL is called which is "Input requested", when click this hyperlink it gives a new form to fill the request values, if that will not be filled it will give error.

Jenkins pipeline with parallel stages causes "process apparently never started" error

I'm trying to set up a Jenkins pipeline (using the declarative syntax) that runs unit and feature tests on two separate, on-demand AWS EC2 instances. The pipeline works perfectly when run on a single instance and without the parallel stages. As soon as I switch to parallel stages, any shell script fails with this cryptic message:
process apparently never started in
/home/admin/workspace/GSWebRuby_Test#tmp/durable-b0d8c4b4 (running
Jenkins temporarily with
-Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true
might make the problem clearer)
I've googled extensively and came across several bug reports of the Durable Task plugin that appears to be responsible for this message. I'm using the latest version of the plugin v. 1.33 and none of the problems seem to apply to my case, e.g. failures on unusual architectures or when running Docker containers. I've also down- and re-upgaded the plugin (toggling between versions 1.30 and 1.33). Also, to re-iterate, sh commands work without issue when I don't use the parallel stages.
I've created a simplified pipeline to debug the problem. Note that the shell commands are also simple, e.g. "env | sort", or "pwd".
pipeline {
agent none
environment {
DB_USER = credentials('db-user')
DB_PASS = credentials('db-pass')
}
stages {
stage('Setup'){
failFast false
parallel {
stage('foo') {
agent {
label 'jenkins-slave-ondemand'
}
steps {
echo 'In stage foo'
sh 'env|sort'
}
}
stage('bar') {
agent {
label 'jenkins-slave-ondemand'
}
steps {
echo 'In stage bar'
sh 'pwd'
}
}
}
}
}
}
This is the console output:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] withCredentials
Masking supported pattern matches of $DB_PASS or $DB_USER
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Setup)
[Pipeline] parallel
[Pipeline] { (Branch: foo)
[Pipeline] { (Branch: bar)
[Pipeline] stage
[Pipeline] { (foo)
[Pipeline] stage
[Pipeline] { (bar)
[Pipeline] node
[Pipeline] node
Still waiting to schedule task
All nodes of label ‘jenkins-slave-ondemand’ are offline
Still waiting to schedule task
All nodes of label ‘jenkins-slave-ondemand’ are offline
Running on EC2 (Jenkins AWS EC2) - Jenkins slave (i-0982299c572100c71) in /home/admin/workspace/GSWebRuby_Test
[Pipeline] {
[Pipeline] echo
In stage foo
[Pipeline] sh
Running on EC2 (Jenkins AWS EC2) - Jenkins slave (i-092ecac8e6c257270) in /home/admin/workspace/GSWebRuby_Test
[Pipeline] {
[Pipeline] echo
In stage bar
[Pipeline] sh
process apparently never started in /home/admin/workspace/GSWebRuby_Test#tmp/durable-b0d8c4b4
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
Failed in branch foo
process apparently never started in /home/admin/workspace/GSWebRuby_Test#tmp/durable-b6cfcff9
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
Failed in branch bar
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE
Am I doing something wrong in the way I've set up the pipeline? Any pointers would be greatly appreciated.
Edit:
After setting this JENKINS_JAVA_OPTIONS org.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true, I see this additional output:
In stage bar
[Pipeline] sh
nohup: failed to run command 'sh': No such file or directory
process apparently never started in /home/admin/workspace/GSWebRuby_Test#tmp/durable-099a2e56

Failed to deploy artifacts: Could not transfer artifact

I'm trying to deploy the artifacts , lets say "demo.war" into my remote nexus and facing following issue. We recently upgraded our plugins/jenkins (before this the pipeline job was working fine).
Not sure what went wrong still couldn't resolve this error.
Could anyone spot the error?please.
Failed to deploy artifacts: Could not transfer artifact :demo:war:1.0.1 from/to releases (http://demo_server_url:8081/nexus/content/repositories/releases): Failed to transfer file: http://demo_server_url:8081/nexus/content/repositories/releases/demo-server/1.0.1/demo-1.0.1.war. Return code is: 500, ReasonPhrase:Server Error.
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Uploading file demo.war failed.
Finished: FAILURE

sfdx error while running in Jenkins pipeline

Can anyone help me this issue in sfdx. I was able to execute scratch org and package version creation using Jenkinsfile. But getting an error while installing metadata on scratch org and sandbox.
[Pipeline] sh
[SFDX_SFDX_Package_Installation] Running shell script
+ sfdx force:package:install --wait 10 --publishwait 10 --package sfdx_naresh#0.1.0-1 -k nar123 -r -u scratchorg#so7.org
autoupdate:: /root/.cache/sfdx/update.lock is locked with an active
writer
ERROR: INVALID_HEADER_TYPE.
[Pipeline] error
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Package Installing Failed
Finished: FAILURE

Getting Jenkinsfile error - command not found

What is wrong with this Jenkins file? I am new to it but I don't get what am I doing wrong
pipeline {
agent any
stages {
stage('Test') {
steps {
dir ('/var/lib/jenkins/workspace/pipleline_2') {
}
}
}
}
post {
always {
sh 'hello2.sh'
}
failure {
mail(from: "heenashree2010#gmail.com",
to: "qshoretechnologies#gmail.com",
subject: "That build passed.",
body: "Nothing to see here")
}
}
}
I am getting below error. hello2.sh exists in the directory which I have specified but I am not able to execute it. I also tried sh('hello2.sh') but it didn't work for me. What am I doing wrong?
Started by user qshore
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/pipleline_2
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/pipleline_2
[Pipeline] {
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] sh
[pipleline_2] Running shell script
+ hello2.sh
/var/lib/jenkins/workspace/pipleline_2#tmp/durable-dbcba8b2/script.sh: line 2: hello2.sh: command not found
[Pipeline] mail
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
The script called hello2.sh is not found. Make sure that it is included in the repo that you're checking out.

Resources