How to deploye .war file in jboss server using shell script - shell

I am on RedHat, using Jboss 5.x and Jenkins. My Jenkins is building the project perfect. I am coping the war file to deploy folder of Jboss with shell script.
When I am running the command on my terminal
scp source/example.war destination/deploy
scp command is able to copy the .war file into deploy folder and through url I am able to access it.
But the when I am writing the same command on jenkins it throws an error.
Permission denied
Build step 'Execute shell' marked build as failure
I guess it is because jenkins try to write the file and it does not have permission.
so how do i do that??

If you are using SCP to copy your file from the Jenkins server to your Jboss server, you should declare the public SSH key of your jenkins user on the Jboss Server.
Please have a look to this answer: add a publickey to server for SCP

Related

How does the Jenkins config file provider plugin work?

How does the config file provider plugin work?
I have a Jenkinsfile for a declarative pipeline (multi-branch build) that contains:
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn -B -s $MAVEN_SETTINGS -DWHERE="$WHERE" deploy'
}
I have tried running this on two different Jenkins installations one which is installed directly and runs as daemon and another running as a container (jenkinsci/blueocean).
When run on the direct the Jenkins Config File Provider plugin is able to provide the required settings.
provisioning config files...
copy managed file [Maven settings] to file:/var/lib/jenkins/workspace/redacted#tmp/config8989354118161621860tmp
When run under the jenkinsci/blueocean container it fails with:
provisioning config files...
not able to provide the file [ManagedFile: id=maven-settings, targetLocation=null, variable=MAVEN_SETTINGS], can't be resolved by any provider - maybe it got deleted by an administrator
I have created a managed maven-settings.xml file with id maven-settings for blue/ocean but it is not being picked up.
I've also tried copying it to ~/.m2/settings.xml
By contrast the working installation does not have any managed files (settings.xml or otherwise) and I am unable to locate any maven settings file in the workspace. I'm not sure what the #tmp directory is. It is deleted by the time a build finishes.
So my question is:
Where should I put the settings to make the configFileProvider pass them on for the jenkinsci/blueocean build job?
How does the config file provider plugin work?
I have no idea what its doing so its hard to debug. The source is here but Java, Maven & Jenkins are not my main area.
What differences are there when Jenkins itself run as a container?
This answer suggests the the config file provider is unnecessary.
There is a similar question which is unanswered but it relates to a maven plugin.
I have part of the answer. My maven-settings file wasn't being picked up because I was using the file name rather than the file Id which is different.
The remaining part of the question is how is the original Jenkins instance able to generate this file without it being listed as a managed file.

Jenkins Deployment Issue

I'm using Jenkins to deploy war file into tomcat.Build is success but giving FileNotFound exception.I'm using tomcat7.I found some references in google but didn't get the solution
if you want to copy war from build server to tomacat server ,use robocopy to copy war to tomcat server
robocopy c:abc/abc.war //tomcatserver and path
Most containers have a directory where you can "place" the war, in order to deploy it.
Therefore in Jenkins you can set up Send build artifacts over SSH
More
On configuring the server, you should go in Configure Jenkins -> Configure system -> SSH Servers
Add the server you need to deploy to, username (+password) and Remote directory: /opt/app/tomcat/webapps (or whatever)
More info here - https://wiki.jenkins.io/display/JENKINS/Publish+Over+SSH+Plugin

Jenkins execute shell not able to find gradle commands

I am trying to trigger gradle command in execute shell of a particular node from jenkins master and it's trowing an exception as-
gradle: command not found
Build step 'Execute shell' marked build as failure
However, gradle command works if am trying to execute shell in the same node itself under local workspace.
What I understood-
Triggering any job from remote by default try to search executable like 'adb', 'gradle' in /usr/local/bin of node machine (Macintosh)
read-write access should be there for '.gradle' folder
What I have done-
added .gradle inside /usr/local/bin of slave
granted read-write access to .gradle
Here, both node-jenkins and master-jenkins have gradle v2.5 installed. Why execute shell triggered from master jenkins not able to find gradle in slave jenkins, any help would be appreciated.
try run env before your try to run gradle. and compare it to env from the command line. I think that Jenkins use another path.
I was also facing same issue where gradle command working fine on machine where jenkins is installed but the same command was not working on slave.
Solution:
You need to set GRADLE_HOME on slave.
Most important: set PATH into the slave configuration [copy the exact PATH path from slave machine and copy it into Jenkins slave configuration under Jenkins--> Manage Jenkins--> Manage Node--> NodeName(your node name)--> Configure and search for Node Properties-->Environment variables]
save
In my case I have added additional PATH env variable, then it worked.
I was also facing same issue
verify you add Gradle Plugin to your jenkins
Verify that you inside the Folder where exist the "gradle.build" file
my example: the location of my gradle.build was insifr the foulder automation-api

Jenkins copy to hdfs

I have tried several artifacts plugins for Jenkins but so far have been unsuccessful with the task:
I use hadoop as a file system for deployments and deploy my app from hadoop (mesos/marathon can only access http or hdfs). How do I make Jenkins save the artifact zip from sbt to hdfs? I doesnt give me the option to run a shellcommand
The plugin Hudson Post build task lets you run shell commands and copies the necessary files to hadoop as a shell script

Copying files between two windows servers through jenkins

I am working on a project where i want to copy the compiled file (which compiled through jenkins) from one windows server to another through jenkins. Jenkins is installed on a windows server and after building the code, those compiled file should be copied to another windows server through jenkins. Is there any way to achive it?
Jenkins might be able to do it, via the script steps running the scp command; however, if this is part of a build, I would suggest attaching the file(s) to a project, and distributing them through the maven repository.

Resources