I created a job in jenkins with maven for my java project. My jar name is
artifactId-version.jar and I am deploying this jar to artifactory server. I
have 5 to 6 jar files like this which are deployed to artifact.
My build command is
clean install -Dversion=$BUILD_NUMBER -Denv=r -DskipITs
so that my jar is like example-r-23.jar and under execute shell I have written as
echo $BUILD_NUMBER > src/sonarCharts/latest.txt
and sending this file to Artifactory. I am using curl command to read the
value in latest.txt file and downloading jar file.I am downloading them from
my code through shell script (using wget command like wget --user --
password http://artifactory/example-1.0.jar).
This process repeats for every release. Once i deliver my code to production,
i am changing this version to 2.0 and now jar file will be like example-
2.0.jar and deploying it to artifact.I need to change my script file every
time jar version is changed.
<artifactId>rabbitMQHandler</artifactId>
<version>1.0</version>
<name>rabbitMQHandler</name>
<url>http://maven.apache.org</url>
I followed one procedure by overwriting the version with Build number and
passing it from command line as
mvn clean install -Dversion=$BUILD_NUMBER --- to build
and i am sending this BUILD_NUMBER to one txt file as
echo $BUILD_NUMBER > latest.txt --- sending this to artifactory
and placing that file in artifactory. I am reading that txt file through shell
script using curl and i am using that number in wget command.
I feel my way of doing is not correct and is there any other way of doing it.
Related
Background: I am renaming a certain set of env specific files in my source code via jenkins pipeline before publishing the artifact to nexus using mvn deploy goal
I'm using mv command to rename the file
mv <env>config.properties config.properties
This does rename the files successfully and when I download the zip from output console of jenkins, I have the renamed files(config.properties) in zip
But the very next time I download it from nexus or from the output console again, It gives a zip file with old file name config.properties. It is somehow renaming it back to original name.
Has anyone faced this before? Any inputs would help
I'm trying to install Datomic on a Windows 10 computer, following the official instructions.
I downloaded and unzipped the dev tools as instructed.
I cannot, however, run the install script because it is a bash script.
I opened the script and discovered it requires maven, so I installed maven and tried to run the commands manually.
echo 'Installing: com.cognitect/rebl {:mvn/version "0.9.242"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=rebl-0.9.242/rebl-0.9.242.jar
echo 'Installing: com.datomic/dev-local {:mvn/version "0.9.232"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=dev-local-0.9.232/dev-local-0.9.232.jar
At first this errored with
The goal you specified requires a project to execute but there is no POM in this directory
So I figured out how to create a maven pom.xml.
Then it errors
[ERROR] The specified file 'C:\workspaces\clj-recipe\rebl-0' not exists
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file (default-cli) on project clj-recipe: The specified file 'C:\workspaces\clj-recipe\rebl-0' not exists
Is dev-local not intended for windows?
Update
I did get the maven scripts to run. I created my own install.ps1 in the dev tool directory, which kept paths the same, and quoted the file paths.
# expects to be run from the project (pom.xml) directory, but in a script file in the same directory as the original install script
echo 'Installing: com.cognitect/rebl {:mvn/version "0.9.242"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile="rebl-0.9.242/rebl-0.9.242.jar"
echo 'Installing: com.datomic/dev-local {:mvn/version "0.9.232"}'
mvn -q org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile="dev-local-0.9.232/dev-local-0.9.232.jar"
I still can't get dev-local to run though. There appears to be no changes to the pom.xml.
I start up a repl for the current lein project and run
(require '[datomic.client.api :as d])
(def client (d/client {:server-type :dev-local
:system "dev"}))
Getting the error No such namespace: d.
My guess is that I don't understand how deps.edn works... Right now I have a single deps.edn under C:/Users/[username here]/documents/.clojure/deps.edn
{
:mvn/repos {"cognitect-dev-tools"
{:url "https://dev-tools.cognitect.com/maven/releases/"}}
:deps
{com.datomic/dev-local {:mvn/version "0.9.225"}}
}
There were two key issues here
The install script is not necessary with leiningen (and is not written for windows)
If you want to use a maven-based approach, then use the install script. Be warned that you need maven installed.
The install script can be tweaked for windows by changing as shown above (quote paths, remove the cd, make it a ps1 file)
The deps.edn, maven, and leiningen paths are not compatible. I must configure the dependency using leiningen to use it in my lein-based project
Configuring for lein is fairly simple
add a repositories configuration section
add a package dependency
(defproject ;;...
:dependencies [
;;...
[com.datomic/dev-local "0.9.225"]
]
:repositories [
["cognitect-dev-tools" {:url "https://dev-tools.cognitect.com/maven/releases/"
:username :env/datomic_username
:password :env/datomic_password}]]
;;...
)
Note that the credentials have to be supplied to the lein project. This can be done with
environment variables as shown above (specify the name as :env/var-name-here)
or using an encrypted password field
or use a profile
I need to write an yaml script to get the most recent artifact from artifact repository and store it in a windows server.
Repository Browser Structure would be like the below
Name of the Repo - Generic_App
TEST_APP is a folder inside the repo.
Generic_App->TEST_APP->1->TEST_APP-1.ZIP
Generic_App->TEST_APP->2->TEST_APP-2.ZIP
Generic_App->TEST_APP->3->TEST_APP-3.ZIP
Can you help me with the script to download TEST_APP-3.ZIP
You requested for a yaml script. I guess it'll be easy for you to embed the following command in any script you may be using.
The following JFrog CLI command downloads the latest file from Artifactory, which matches your requirements. The command will look for the newest file created, which path and name matches the following pattern (notice the wildcard in the file name pattern) -
Generic_App/TEST_APP/TEST_APP-*.ZIP
jfrog rt dl "Generic_App/TEST_APP/TEST_APP-*.ZIP" --sort-by created --sort-order desc --limit 1 --url "<artifactory url>" --user "<artifactory username>" --password "<artifactory password>"
Note: In most cases, the Artifactory URL ends with /artifactory
If the machine which runs the script doesn't have JFrog CLI installed, here's how you can install it - https://jfrog.com/getcli/
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.
I have a build step that builds my projects and packs it into a myfile.jar and put it in my artifacts dir.
i have also told jenkins to archive the myfile.jar.
now i want to add another build step to execute shell command java -jar myfile.jar and install it for further testings
how can i tell jenkins to point to myfile.jar when executing the shell command ? i don't know the artifacts dir name since it's dynamically created with build number etc...
thanks.
The artifacts directory is on the master, not the slave.
If both are on the same machine for you, the artifacts reside at:
$JENKINS_HOME/jobs/$JOB_NAME/$BUILD_ID/archive
However, like Anders Lindahl said, archiving an artifact does not delete it from the workspace; why not use it directly from there. Generally, you do not want to disturb the archives directories...