Run a Curl comand from a jenkins job - shell

can anyone tell me how we can run a curl command from jenkins.
I'm on windows 7 and i'm trying to put .sh on artifactory from a job jenkins.
thanks

So I understand that you want to upload a file to Artifactory by using curl and Artifactory's REST API?
The easiest would be to use the Artifactory plugin, and upload files from your workspace into an Artifactory repository.
If you want to do it without that:
Install cURL for Windows on the node
Add a "Windows batch script" build step, and call cURL with the right URL

Related

How to setup a Jenkins job for Veracode Scan in a Node application?

My Jenkins runs on AWS EC2 instance and I'm creating a freestyle job to run Veracode Scan. I configured my Veracode portal API credentials with the Job. Installed the Veracode Jenkins plugin as well. And the Git repo also set upped in the pipeline. So my plan was to Zip the git repo by running below shell script
Then in the post build section I configured to upload the zip file like shown in below image.
When i build the job it throws below error.
it says that zip is not found. What may be the reason for this error? Also am I approaching this in a correct way?

Where does Jenkins store the project source

I have a Jenkins job that uses a script to build my project. On the following line, the script fails mvn -e -X -Dgit='$git' release:prepare.
Because I want to search for the cause of this, I want to go to the Jenkins server and run mvn -e -X -Dgit='$git' release:prepare from the command line, to see if it works.
Does Jenkins store the projects' source code somewhere, such that I can go to that folder and call Maven?
If yes, then where?
Yes, It Stores the project files for the job by default at
/var/lib/jenkins/workspace/{your-job-name}
This is where jenkins suppose the project files to be present or it pulls it from a source before start working/building from it.
Quote from Andrew M.:
"Hudson/Jenkins doesn't quite work that way. It stores configurations and job information in /var/lib/jenkins by default (if you're using the .deb package). If you want to setup persistence for a specific application, that's something you'll want to handle yourself - Hudson is a continuous integration server, not a test framework.
Check out the Wiki article on Continuous Integration for an overview of what to expect."
From this Question on serverfault.
This worked for me:
/var/jenkins/workspace/JobNameExample
but, if your build machine (node) is a different than the one where Jenkins is running (manager), You need specify it:
/var/jenkins/workspace/JobNameExample/label/NodeName
Where you can define label too:
jenkins stores its workspace files currently in /var/jenkins_home/workspace/project_name
I am running from docker though!

Something like “mvn undeploy” to remove artifacts from Nexus?

After a mvn deploy (to a local Nexus) on a project with more than 50 modules I realized that the deployed artifacts had all wrong file names (suffix zip instead of war etc).
Is there something like mvn undeploy to remove these from Nexus again?
You can delete it by using Curl command :
http://host:port/nexus/service/local/repositories/repo-id/content/group-id/artifact-id/version
The delete request can be sent with these parameters, I like to suppress the output except HTTP status code, so that it’s easier to check the result of a series of such commands run from shell script.
curl –request DELETE –write “%{http_code} %{url_effective}\\n” –user admin:admin123 –output /dev/null –silent url
For example you can execute this script from a Freestyle jenkins job.

How to execute remote bat file using build step in TeamCity?

I have TeamCity installed on centos. I have only one Linux BuildAgent for now. My build configuration execute a maven script and using ant upload WAR artifact to Windows Server on FTP. After this step i have to execute BAT file on remote Windows Server. I read that i can do this using psexec/RemCom, but i can't understand how i can do this in TeamCity? Build Step or different Build Configuration should contain steps to execute psexec/RemCom or i can insert Build Step into existed Build Configuration?
Single build configuration could potentially consists of multiple build steps. Think of them as a actions you would like to do. So I suppose that right now you have a maven step in your build configuration. I would suggest you to add Command Line step, where you can do what ever you want -- it's like bash/batch script. You can put script contents directly to the build step, or you can write script and execute it.
But as you mentioned that you have CentOS, it could be you have to do extra configuration on the build agent for PsExec to be available.

Jenkins CI + Ant + SSH Plugin

So the way I have this setup is:
Jenkins Polls for changes on repo
Jenkins Initiates Ant
Jenkins uses SSH plugin to run a script on a remove server (to run a git pull)
The problem is that if Ant fails, Jenkins still moves on to step 3 and processes the script.
How do I make Jenkins just stop everything after step 2? Or is there a better way of doing my process?
I think what I really needed was Publish Over SSH instead. This enables you to include it in the Post Build Options.

Resources