Automated Deployement Build Failed in Jenkins - jenkins

I am doing automated deployemnt in jenkins and getting error saying that:
Build step 'Execute Windows batch command' marked build as failure.
Building on master in workspace:
C:\Program Files (x86)\Jenkins\workspace\AutomatedDeployement1
[AutomatedDeployement1] $ cmd /c call C:\Windows\TEMP\jenkins1993620515430909066.bat
C:\Program Files (x86)\Jenkins\workspace\AutomatedDeployement1>date
The current date is: 08-06-2020
Enter the new date: (dd-mm-yy)
C:\Program Files (x86)\Jenkins\workspace\AutomatedDeployement1>exit 1
Build step 'Execute Windows batch command' marked build as failure
[DeployPublisher][INFO] Build failed, project not deployed
Finished: FAILURE
Your answer will help me in learning. Thanks In advance

The "marked build as failure" message happens because of the exit code in your batch file. Try exit 0 instead of exit 1.
You can also instruct Jenkins to continue building even though there was a build error.

Related

Jenkins can't find directory when executing shell command

I want to execute these shell command in my Jenkins job.
cd /Users/username/Desktop/JenkinsProject
javac Jenkins.java
java Jenkins
However when I try to build I get the error:
Running as SYSTEM
Building in workspace /Users/Shared/Jenkins/Home/workspace/JenkinsExample
[JenkinsExample] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh
+ cd /Users/username/Desktop/JenkinsProject
/Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh: line 2: cd: /Users/username/Desktop/JenkinsProject: Not a directory
Build step 'Execute shell' marked build as failure
Gitcolony notification failed - java.lang.IllegalArgumentException: Invalid url:
Finished: FAILURE
It looks like it can't find the folder when running the commands with Jenkins?
If I dont use Jenkins but run the commands in my terminal everything works fine.

Jenkins fails Jest tests that otherwise works (corporate proxy)

I am sitting behind corporate proxy.
So basically test is just page.goto("https://") I created Freestyle project and made it execute code in command line:
cd C:/Testing
npm test -- Jenkins
If I run these commands on machine where Jenkins is running, everything works and test passes. However, if I run it using Jenkins, this error appears:
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Main Project
[Main Project] $ cmd /c call C:\Windows\TEMP\jenkins7770552654778169643.bat
C:\Program Files (x86)\Jenkins\workspace\Main Project>cd C:/Testing
C:\Testing>npm test -- Jenkins
> testing#1.0.0 test C:\Testing
> jest "Jenkins"
FAIL .\Jenkins.test.js (5.023s)
Describe
× Test (513ms)
� Describe › Test
net::ERR_TUNNEL_CONNECTION_FAILED at https://google.com/
at navigate (node_modules/puppeteer/lib/Page.js:539:37)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 6.587s
Ran all test suites matching /Jenkins/i.
npm ERR! Test failed. See above for more details.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I checked Jenkins HTTP Proxy Configuration and it was set up correctly (host, port and credentials are all correct), but if I enter https://google.com/ in Test URL and press "Validate Proxy", this error appears:
Failed to connect to https://google.com/ (code 407).
Is there something that can refuse Jenkins requests to websites? Windows Defender firewall is disabled.

How to successfully run selenium test script in jenkins?

I've configured my project to run the Build with Jenkins.
If I execute the testng.xml on my own it successfully executes my test case but if I execute via Jenkins I get the following error message:
Error: Could not find or load main class ûcp Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE

sbt-launch.jar failed - Could not load main class

I have a jenkins build to check sbt, which is failing with the below error:
[sbt-check] $ /var/hudson/tools/java1.8.0_51/bin/java /var/hudson/tools/sbt-0.13.12/bin/sbt-launch.jar -Dsbt.log.noformat=true -jar clean assembly
Error: Could not find or load main class .var.hudson.tools.sbt-0.13.12.bin.sbt-launch.jar
Build step 'Build using sbt' changed build result to FAILURE
Build step 'Build using sbt' marked build as failure
Successfully triggered JIRA to update builds of this job
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 9 second
Notifying upstream projects of job completion
Finished: FAILURE
The sbt package is installed on the server. I downloaded package SBT-0.13.12.TGZ from http://www.scala-sbt.org/download.html and created its RPM to install it on my server. Package is installed and I have configured the path of sbt-launch in manage-jenkins.

Build step 'Execute shell' marked build as failure

I have a build step in my jenkins project. This is an Execute Shell step.
The following is the command is what I am running.
sudo gcloud --project=xxxx preview app deploy app.yaml ==version=1
During the deployment the above step breaks the build, with the following error.
sudo gcloud --project=cfc-melbourne-website preview app deploy app.yaml ==version=1
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
No JDK named ‘null’ found
ERROR: Build step failed with exception
com.google.jenkins.plugins.credentials.oauth.GoogleRobotPrivateKeyCredentials$AccountIdNotSetException
at com.google.jenkins.plugins.credentials.oauth.GoogleRobotPrivateKeyCredentials.getUsername(GoogleRobotPrivateKeyCredentials.java:152)
at com.google.jenkins.plugins.credentials.oauth.RemotableGoogleCredentials.<init>(RemotableGoogleCredentials.java:54)
at com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials.forRemote(GoogleRobotCredentials.java:204)
at com.google.jenkins.plugins.storage.AbstractUpload.initiateUploadsAtWorkspace(AbstractUpload.java:342)
at com.google.jenkins.plugins.storage.AbstractUpload.perform(AbstractUpload.java:173)
at com.google.jenkins.plugins.storage.GoogleCloudStorageUploader.perform(GoogleCloudStorageUploader.java:109)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1766)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Google Cloud Storage Uploader' marked build as failure
Finished: FAILURE
How do I resolve this ?
The no tty present error indicates that you have the requiretty setting in your sudoers file. This will require a tty. To solve this you can add your user to that file and turn .
change your sudoers-file:
vi /etc/sudoers
and add (assuming it's your jenkins-user):
Defaults:jenkins !authenticate
Normally your jenkins user can use sudo-commands without authentication.

Resources