Find artifactory URL from another Jenkins build - java

I have a Jenkins job that build and upload an .ear to Artifactory. I'm creating another Jenkins job that will deploy this application on a few servers using ansible. How can I make it find the most recent build and get the artifactory URL for the ear file that was built?

Since you are using jenkins you can use the process of upstream -> downstream or pipeline based process for the deployment of the .ear files.
Artifactory url consists of two parts one fixed and another variable.
For e.g.
fixed --> https://artifact.domain.com:8081/artifactory
variable -- repo_name
https://artifact.domain.com:8081/artifactory/$repo_name/
For getting the lastest build number you can also use the artifactory api key value RELEASED
Artifactory REST Api
You can also use jenkins plugin of artifactory for dependencies download to download the .ear file if the app is simple

Related

Can we upload aritfacts (.jar/.zip) created as part of jenkins pipeline to Azure Devops?

I am working on a project which needs me to migrate the storage of artifacts from PVCS to Azure Devops. (Problem statement was provided like that)
Current Setup:
The Jenkins Pipeline takes a master.xls file from a folder created (unique for each build number) in PVCS and based on the data manually entered into master.xls, it interacts with Pega DB and creates an Artifact (Rules.Zip).
To interact with the PEGA DB, the Jenkins job executes few Java programs and executes a few batch and ant scripts. The ant scripts produce the artifacts.
Finally it stores that artifact in the same PVCS folder created initially with an empty master.xls file.
Jenkins is interacting with PVCS usling PCLI commands which will be executed from Java programs run by Jenkins jobs.
Required Setup:
The PVCS needs to be replaced with Azure Devops, i.e. the Jenkins Pipeline should be able to do the following:
Create a folder in Azure Devops with an empty master.xls
After master.xls is updated manually, The pipeline should be interacting with Pega DB as usual and store the artifact thus created into Azure Devops.
I am pretty new to Azure Devops. Kindly help me understand if the said requirement is possible and If so, how can that be achieved. A list of abstract steps would be of great help. I will work on them.
There is Jenkins Download Artifacts task in azure devops pipeline that you can make use of to download the artifacts from Jenkins pipeline to azure devops pipeline.
First you need to create Jenkins service connection in your azure devops project.
Open the Service connections page under the project settings page, and select New service connection and choose Jenkins.
Then you can initialize a empty azure repo. Click the + beside your project name and select New Repository
Then you need to create a build pipeline, selecting your azure repo as the location of your source code. Below example is in classic view(Choose use the classic editor to create a classic view build pipepline).
Then choose start with an empty job to create a empty build pipeline
When your pipeline is initiated you can add Jenkins Download Artifacts task to download the artifacts from Jenkins pipeline.
And you can add command line task to run git command in your pipeline to commit and push the artifacts to your azure repo.
You can also add Publish build artifacts task to publish the artifacts to azure devops pipeline server.
Here is more information about how to integrate Jenkins with azure devops.
I am suspecting you want the file stored in version control... Right? Cause, like #DanielMann suggests, you can attach the file as a Build Artifact or as a package in an Artifact feed. You can use the Azure CLI + DevOps extension to interact with the package feeds:
If you want to store it in version control... What kind of version control has been selected in Azure DevOps, Git or TFVC?
If TFVC, you can use tf.exe from jenkins or this set of tasks for Azure Pipelines to store the artefact in TFVC.
If Git, you can use git.exe in both jenkins and Azure Pipelines to add, commit and push the changes to the Git repository.

How to deploy to AEM instance via Repository?

Is it possible/ how do you take an packaged version of a jar via a repository (for example Artifactory) and deploy it to an instance of AEM?
Could this be done via Maven and Jenkins in an automated way?
Currently this is done, only by using a tagged version in a VCS to build and then deploy via the content-package-maven-plugin.
With Jenkins you have multiple options:
You could let Maven build the artifacts for you
or you could use the Repository Connector Plugin (1) to get the artifacts from Nexus / Artifactory
After that, just use the CRX Content Package Deployer Plugin (2) to upload the packages to your AEM instance.
The Jenkins build could be triggered manually, by change in the VCS,...
(1): https://wiki.jenkins-ci.org/display/JENKINS/Repository+Connector+Plugin
(2): https://wiki.jenkins-ci.org/display/JENKINS/CRX+Content+Package+Deployer+Plugin

Continuous integration - git flow

I'm really nooby in 'Continuous integration'. And have a question about it.
Is it possible to create jar, ear or war file and deploy it on jboss every time I merge my develop branch (release) with master branch. I user gradle for build my project. I prefer something without user interface. My server runs on ubuntu server.
You should use a build server (like Jenkins) that could be configured to poll your git repository and run the build upon commit and on a successful build it would deploy (by a script or some plugin) the build product (jar/war) onto your JBoss server.

Resolve/Download dependencies after deployment to remote server

I have a big war file over-sized due to lots of external dependencies & also I have internet connection speed issues because of which I don't want to keep the dependency jars in my war, so that I could reduce war size & do faster uploads of my updated wars from dev machine to remote server.
I would like the maven project to instead download the dependencies on the remote tomcat server itself when it has been uploaded there & starts running. How do I configure maven to do that ?
There is a pretty simple solution: Build the project on the server.
An easy way to do this is to put all the sources into a version control system like Mercurial or Git.
In addition to giving you a history and an automated backup, DVCS have insanely efficient algorithms to update remote copies (they just transfer the changes, so if you change a single line, only one line is sent over the wire).
Building on your server also means that you get the very fast download of dependencies on the server (which has probably very good download rates). And local deployment will be very, very fast.
Last but not least: When you use version control, you will be able to go back to the last stable version quickly when something goes wrong.
As Aarom says you should build the project on the server directly.
There are two requirements:
You need to have a command line access on the remote server.
Maven must be installed on the remote server.
Then you can upload the sources of your project on the remote server (without dependencies).
Go in the root directory of your project and run your build command (mvn package or whatever custom build command that you use).
So that's it, you have the .war on the remote server loaded with all the dependencies; you can then remove the source files.
#user01
Install all desired 3rd-party jars to Tomcat's lib folder.
Set the scope of those dependencies to "provided" in you Maven pom.xml.
Install Maven on your remote server.
Install a CI server such as Jenkins, Continuum, Bamboo, Hudson, CruiseControl, etc. I'd suggest Jenkins.
Hopefully, you are using revision control software such as SVN, Git, Mercurial, Bazaar, or CVS. If not, then I'd suggest setting up
Git or SVN for your source code repository.
Configure the scm tag in your pom.xml to point to your project's location within your source code repository.
Configure your CI server to get your pom.xml from your source code repository. Your CI server will read the scm tag, and the
URL's you've configured within the scm tag, and will check your
project out. Your CI server will then build your project.
You can either have Jenkins deploy your built war artifact to Tomcat via the Jenkins Deploy Plugin, or you can use a Maven plugin such as the
tomcat7-maven-plugin or Cargo.

Using Maven with Sourceforge.net

For a new project which uses Maven I would like to add distributionManagement configuration in the pom.xml which will connect the project with the Sourceforge.net file upload system.
I have found this information (of 2007), is it still valid or do you know updated resources?
http://docs.codehaus.org/display/MAVENUSER/MavenAndSourceforge
Related question: How can I deploy artifacts from a Maven build to the SourceForge File Release System?
This looks correct. However, note that it only describes deploying the site artifacts, not the project artifacts (JAR and POM). And while it's possible that you could use maven to deploy your artifacts, I'm not sure that you'd want to -- the Maven directory structure is different from the SourceForge structure (of one directory per release).
If you're looking to deploy your project releases to Maven Central, read this: http://maven.apache.org/guides/mini/guide-central-repository-upload.html
The process has changed in the last year or so. At one time you could request that your project be added to a nightly rsync job, but apparently now you have to deploy directly to a recognized repository. Given the number of times that rsync job would fail, it's no wonder they decided to change the process ...

Categories

Resources