zip -urj command fails in jenkins pipeline shell script - shell

I have jenkins job that add the files to existing zip file
Below is the command that I am using:
zip -urj ./$zipFileName ./template/CM/provision/start.sh
This runs sometimes and sometimes it fails
Here is the log i get on failure:
Build step 'Execute shell' marked build as failure

Related

Script is not running in Xcode build phase

In my package.json file I have a script that I'm running
node src/validateRun.js
I'm trying to run that script in the Xcode build phase. the script is located in the src/ so the build is successful but the script is never running.
Here is my build phase config:
shell: /bin/sh
SRC_DIR="../src/"
node "$SRC_DIR/validateRun.js"
is there any reason why the script is not running ?
Apparently instead of execute node file.js you should type it like this:
/usr/local/bin/node your_file.js

Jenkins execute shell

I have a jenkins job which is having 5 build scripts configured in job execute shell. Now I have a flag in script#1 if it's false then I don't want to run remaining 4 build scripts and directly exit then build results should be pass.
But now even after checking script#1 flag is false it's exiting from script#1 and executing remaining 4 build scripts then all the 4 scripts are failing due to dependency with script#1 finally my jenkins build status is failed.
I want after checking script#1 job could exit and directly jenkins job status should be "pass"
Is there anyway in jenkins itself to control this flow? without writing any code in scripts?
Jenkins error :
------------
23:37:16 Nothing to build
23:37:16 SRV_SKIP_UNNECESSARY_BUILDS is set to 1
23:37:16 Exiting now...
23:37:16 +++/usr/atria/bin/cleartool rmview -f -tag swrel_sre_icx_test_ashok_diffreportvu_20180118_233612
23:37:30 SRE_FYI: No rebuild necessary for sre_icx_test_ashok since previous full build[EnvInject] - Injecting environment variables from a build step.
23:37:30 [EnvInject] - [ERROR] - The given properties file path '/var/tmp/jenkins/workspace/Test/sre_icx_test_ashok/srv_env_strip' doesn't exist.
23:37:30 [EnvInject] - [ERROR] - Missing file path was resolved from pattern '${WORKSPACE}/srv_env_strip' .
23:37:30 [EnvInject] - [ERROR] - Problems occurs on injecting env vars as a build step: java.io.IOException: remote file operation failed: /var/tmp/jenkins/workspace/Test/sre_icx_test_ashok at hudson.remoting.Channel#1c0be696:l42-up-ecbld-01: java.io.IOException: The given properties file path '/var/tmp/jenkins/workspace/Test/sre_icx_test_ashok/srv_env_strip' doesn't exist.
23:37:30 Build step 'Inject environment variables' changed build result to FAILURE
23:37:30 Build step 'Inject environment variables' marked build as failure
23:37:30 Set build name.
23:37:30 Unrecognized macro 'SRV_BUILD_LABEL' in '#22 - ${SRV_BUILD_LABEL}'
23:37:30 Archiving artifacts
23:37:30 SSH: Current build result is [FAILURE], not going to run.
23:37:30 [description-setter] Description set: ${SRV_BUILD_DIR}
23:37:30 Notifying upstream projects of job completion
23:37:30 Finished: FAILURE
In theory, you could do so by acquiring a Jenkins plugin called "Fail The Build" and change your job so that:
The first build step writes a flagvar=value to a file which can later be sourced by another script, and then exits with a failure. The failure will skip out of running subsequent build steps and go straight to the post-build actions.
Then you can set in the post-build "Execute a set of scripts->Build steps->Execute shell". Set it to execute steps only if build fails, and then in the first step have it source the first build step's file written to see if it was an abort or an actual failed build. If a failed build, exit again with an error - otherwise let it go to the next post-build build step which calls Fail The Build to change the job status back to Success.
I have not tried this to see if it actually works.

build failure Jenkins+Maven+SVN

Started by user xxx
Building in workspace C:\Users\Vinay.jenkins\workspace\Orbit App Automation
Updating https://polarisdev.svn.cloudforge.com/qaautomation at revision '2017-12-01T11:04:13.362 +0530'
Using sole credentials xxxx/****** in realm ‘https://polarisdev.svn.cloudforge.com:443 CloudForge login’
At revision 5
No changes for https://polarisdev.svn.cloudforge.com/qaautomation since the previous build
[qaautomation] $ cmd.exe /C "D:\apache-maven-3.5.0\bin\mvn.cmd -f pom.xml '"-Dmaven.repo.local=C:\Users\Vinay.jenkins\workspace\Orbit App Automation.repository"' clean install && exit %%ERRORLEVEL%%"
POM file pom.xml specified the -f/--file command-line argument does not exist
Build step 'Invoke top-level Maven targets' marked build as failure
Sending e-mails to: vinaya.mopidi#orbitanalytics.com
Finished: FAILURE
It is working now ,earlier i have given incorrectly Repository URL (svn url) now given up to svn work space
Correct : https://xxxx.svn.xxx.com/qaautomation/xxxAutomation
InCorrect : https://xxxx.svn.xxx.com/qaautomation
Build step 'Invoke top-level Maven targets' marked build as failure because you entered your shell script in maven goals and options input field.
You command seems to be a free style windows command script .
cmd.exe /C "D:\apache-maven-3.5.0\bin\mvn.cmd -f pom.xml '"-Dmaven.repo.local=C:\Users\Vinay.jenkins\workspace\Orbit App Automation.repository"' clean install && exit %%ERRORLEVEL%%
Select the execute windows batch command radio button in the build step.

Maven wrapper in jenkins

I'm trying to test build a maven based project in jenkins.
https://github.com/tonsV2/Lift-Log-Backend
However I get the following error.
[Lift Log Backend] $ /bin/sh -xe /tmp/hudson4180120395829748105.sh
+ ./mvnw clean
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Any clues?
Seems like you have spaces in your Jenkins job name. Try to rename your job from "Lift Log Backend" to "Lift-Log-Backend"
I had the same issue, after renaming the Jenkins job, the error was gone.

Unable to execute maven command on jenkins

I have a jenkins job that checks out code from TFS and executes a test class using testng.xml
I have Maven properly installed in my machine in C:\JenkinsDependencies\apache-maven
It has mvn.bat file in its bin folder.
But when I execute my job, it fails with the following error.
Checking for pre-build
[TFS_LN_Mobile] $ cmd.exe /C '"C:\JenkinsDependencies\apache-maven\bin\mvn.bat test && exit %%ERRORLEVEL%%"'
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Build step 'Invoke top-level Maven targets' marked build as failure
Checking for post-build
Finished: FAILURE
Below is the configuration of my jenkins job:
I manually executed a batch command as follows:
cd "C:\JenkinsRoot\workspace\TFS_LN_Mobile"
mvn test -DsuiteXmlFile=testng.xml
This works fine.
mvn.bat is a batch script. you can try adding trace of it's variables after steps that might produce this error. take a look at this: Is there any way to trace through the execution of a batch file?

Resources