I'm in a team to develop plugins in java.
We got Maven, a repository and Jenkins,
And I got myself a debian-server to test my applications.
When I push my commits, this happens:
Push in repository, upload and build in Jenkins.
Users download these .jar files and upload these to their server
What I want to be happen:
There are two ways,
First: After building with Jenkins: Download these files,
Second: When pressing "maven build", maven builds my applications and copy these to my server
How can I do this?
(Sorry for my bad English: I'm German)
If I understand you correctly, following scenario should help.
create two jobs
first job builds your artifact and archives it: user will be able to download it, job is triggered by source modification
second job is only executed manually (and requires two plugins, listed below), copies artifacts from first job and then uploads them to the server
Following plugins you would need to install:
copy artifact plugin to enable jenkins to copy artifacts from another job
publish over ssh plugin to enable jenkins to upload binaries and run commands on remote servers
You want when you push your SCM repository, to get Jenkins build into your local projet (update your jars), then manipulate send your final build to your server. Is that you want ?
If yes, I think that plugin would be interesting :
http://evgeny-goldin.com/wiki/Jenkins-maven-plugin#Supported_Plugins
you can manage jenkins goals from your pom.xml but I am not sure if you can get jenkins build.
Related
when I build a multi pipeline project, I found the dictory only generate one dir:
an-superhub-multipipeline_hades
and the dir an-superhub-multipipeline_hades did not have source code. and other project have 3 dir like this:
an-superhub-multipipeline_master
an-superhub-multipipeline_master#libs
an-superhub-multipipeline_master#tmp
why would this happen, what should I do to fix it? I want to delete the branch and regerate it, but I did not find any delete option in the UI. Only one option to delete all multibranch.
Check logs first:
Job's logs;
System's logs (go to Manage Jenkins - System logs);
logs in jenkins home folder.
What are the differences between develop and hades branches?
If you want to recreate job in multibranch pipeline - delete it on gitlab side, then run scan on jenkins multibranch job, and create branch again.
From my point of view it is better to use Gitlab branch source plugin to automate jobs creation in jenkins and create webhooks in auto manner on gitlab side.
I have created a simple Selenium+java maven project locally on my machine. I am able to execute the testing locally triggering it with Maven.
I want to trigger it from Jenkins (which is installed on a remote machine (my company's QA server))
I am using the option 'custom workspace' of Jenkins.
As the Jenkins is on the server, it's not able to understand/locate the local path
'C:\Automation\MavenProject\'
How I can achieve this?
You can do it with master-slave concepts in Jenkins. Slave machine would be your windows machine which will connect to master Jenkins with the help of some jars. You need to create a node on your Jenkins server and after adding the configuration, you need to download the corresponding slave jars on your machine. Once you execute those jars on your local machine, it will interact with Jenkins server. Your Jenkins job can then perform further activities on your slave machine.
Also in the Jenkins job, you need to refer to this node by enabling the following option.
Restrict where this project can be run
1)Create a Maven Project in Jenkins, you may have to install some plugin if its not visible
Pushing your code to some type of version Control like Github
You need to configure Jenkins to provide GitHub build information and POM Location
Since you Jenkins is hosted up in the server, you have be able to access it public, you need to download Github integration plugin and configure jenkins to provide GitHub hook trigger for GITScm polling and similar action in github itself
This should get you going, also google or youtube, lots of solution , one example
https://www.youtube.com/watch?v=PhxZamqYJws
We have Github repository with the structure as:
Project Name
- submoduleA
- submoduleB
- submoduleC
Every submodule is an extra microservice present inside the same branch. It is maven project. Every submodule is having a seperate jar which are not having any build dependencies.
I want to setup a Jenkins job which will get triggered when there is some changes to the submodule directory and build the respective jar.
Is there any way we can achieve that or is my approach is not correct? I also want to integrate Sonarqube analysis with it.
I suggest you refer to these blogs to setup the automatic trigger process step by step, my favorite is the 3rd blog.
Trigger Jenkins builds by pushing to Github
Automatically triggering a Jenkins build on Git commit
Triggering a Jenkins build from a push to Github
I am trying to build and CI environment and I think that it works because I can publish a jar into Nexus automatically.
Git
BitBucket
Jenkins
Nexus OSS
I am looking information about the deployment of maven projects automatically when it publish to nexus , but I am not sure about my initial idea.
My initial idea is to download the latest artifact from Nexus3 and use mvn spring-boot:run but I am not sure about my decission.
I read information about Puppet but I am not sure about this option, could anyone help to me about this process ? Or send to me another link in the StackOVerflow about this problem.
Regards !
Build a pipeline in Jenkins:
First job builds an artifacts and uploads it to the storage (in your case it's Nexus). It has to determine which version it uploaded - the easiest way to do that is to set the version by the job itself and then upload the known version (see a sample script at the bottom).
Then pass the known version to the downstream jobs (like deploying to envs). You'd need to tell Jenkins which version you just deployed - it's possible to write it into a key-value file and then use something like EnvInject plugin to read it as an env var.
To download an artifact from Nexus use wget/curl:
http://nexus.domain/nexus/service/local/artifact/maven/redirect?r={repository}&g={groupId}&a={artifactId}&v={version}&p={type}
Jenkins has several plugins for building pipelines, but you can start with a simple built-in possibility of jobs to invoke other jobs.
Couple of notes:
Do not use Maven for deployment. Maven is a build tool, it's not suitable for deployments. Write bash scripts and possibly use Docker for deployment automation.
Do not use LATEST/SNAPSHOT/RELEASE versions - you need to have a deterministic deployment (if it's repeated with the same params it deploys the same artifact).
A sample script that sets a snapshot-like version (so it's possible to upload the artifact to snapshot Maven repo):
VERSION=`mvn help:evaluate -Dexpression=project.version | grep -v "^\["| grep -v Download`
VERSION=${VERSION/%-SNAPSHOT/} #get rid of -SNAPSHOT if it's there
VERSION="$VERSION-"`date +"%Y%m%d.%H%M%S"`"-$BUILD_NUMBER"
mvn versions:set -DnewVersion=$VERSION
I have a maven project which I build and deploy on a private remote repository. The code is built through continuous integration pipeline.
This repository is accessible from my remote machine. What I want is to pull the artifact and execute it on this remote machine without pulling the source code for the project.
From what I can understand, one needs a pom file which contains this repo, as a dependency, but is their any other way of doing the same without having to download the sources
If it is possible for you to have just one file to download pushed to Artifactory (I assume you are using artifactory from the tag) it is possible to download the file with a simple http get request (via Artifactory REST API), like curl, or even use the JFrog cli.
I recommend using the CLI: https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory
To use Artifactory REST API directly go to:
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API
Retrieve Artefact api or Retrieve Latest Artefact can be helpful.
you can simply download the file using CLI provided that you have maven installed. Below is an example command.
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=<your nexus url> -Dartifact=<groupid>:<artifactid>:<version>:jar:jar-with-dependencies -Ddest=<destination>
Have you tried the exec-maven-plugin ? http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html
That is if you want to do the job with Maven (it is not very clear to me if you do or do not want to use Maven on your remote machine).
Note : repacking the dependencies in your executable jar would not be a good practice. You can still build a distribution archive along with your jar (look at the maven-assembly-plugin https://maven.apache.org/plugins/maven-assembly-plugin/) and use that archive instead.