I just finished setting up Gitlab Ci to use a Docker container with Maven 3 and Java 8 to build my project. The build successfully completes however when I try to save the generated jar file as an artifact, Docker tells me the artifact has been permanently moved....directly after finding the jar file.
This one has me scratching my head.
Here is my Giitlab CI yml file:
image: kaiwinter/docker-java8-maven
before_script:
- apt-get update --fix-missing
- apt-get install -y git
- git clone -v https://github.com/stefaneidelloth/javafx-d3.git /builds/external/javafxd3
- cd /builds/external/javafxd3/javafx-d3
- mvn install
- cd /builds/external/myDemo
build:
script: "mvn -B install"
tags:
- java8
- maven3
artifacts:
paths:
- target/*.jar
And this is the last few lines from the console from the Job.
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.547 s
[INFO] Finished at: 2017-04-06T17:58:06+00:00
[INFO] Final Memory: 34M/462M
[INFO] ------------------------------------------------------------------------
Uploading artifacts...
target/*.jar: found 1 matching files
WARNING: Uploading artifacts to coordinator... failed id=105 responseStatus=301 Moved Permanently status=301 Moved Permanently token=4pf6n8aT
WARNING: Retrying...
WARNING: Uploading artifacts to coordinator... failed id=105 responseStatus=301 Moved Permanently status=301 Moved Permanently token=4pf6n8aT
WARNING: Retrying...
WARNING: Uploading artifacts to coordinator... failed id=105 responseStatus=301 Moved Permanently status=301 Moved Permanently token=4pf6n8aT
FATAL: invalid argument
Job succeeded
I was able to resolve this. Apparently the docker container, although it could ping the gitlab host, couldnt resolve the artifact-uploader domain name specified in the runner. I changed the runner config in /etc/gitlab-runner/config.toml to the IP of the host machine, and the artifacts copied just fine.
Related
I setup a pipeline on gitlab but I get a weird error "You don't have a SNAPSHOT project in the reactor projects list"
I'm just trying to deploy a java spring boot.
Below the pom.xml (only what's relevant)
<name>Project Phoenix - Base</name>
<groupId>com.gfs</groupId>
<artifactId>phoenix</artifactId>
<version>1.12-SNAPSHOT</version>
<packaging>pom</packaging>
...
<scm>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>git#gitlab.com:"myuser"/phoenix.git</url>
<tag>HEAD</tag>
</scm>
....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.plugin}</version>
<configuration>
<scmDevelopmentCommitComment>#{prefix} prepare for next development iteration [skip ci]</scmDevelopmentCommitComment>
</configuration>
</plugin>
My gitlab-ci.yml looks like this:
workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == 'master'
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
MAVEN_CLI_OPTS: "-s settings.xml --batch-mode --errors --fail-at-end --show-version"
MAVEN_IMAGE: maven:3.8.5-openjdk-17-slim
services:
- docker:dind
stages:
- build
- release
cache:
paths:
- .m2/repository/
- target/
build-job:
image: $MAVEN_IMAGE
stage: build
script:
- echo "Building $MODULE"
- mvn clean package -B $MAVEN_CLI_OPTS
release-job:
image: $MAVEN_IMAGE
stage: release
tags:
- local-runner
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- apt-get update -qq
- apt-get install -qq git
- git config --global user.email "hidden"
- git config --global user.name "hidden"
- git checkout -B "$CI_COMMIT_REF_NAME"
script:
- echo "Creating the release"
- mvn $MAVEN_CLI_OPTS clean deploy release:prepare release:perform
only:
- master
After I push, gitlab starts a pipeline on the commit which is successful and it deploys in the gitlab package registry the snapshot and the release.
However, there are other 2 pipeline starting
[maven-release-plugin] which it seems it does the same things but it fails:
First it says:
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
Then it says: You don't have a SNAPSHOT project in the reactor projects list
$ git checkout -B "$CI_COMMIT_REF_NAME"
Switched to and reset branch 'master'
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
$ echo "Creating the release"
Creating the release
$ mvn $MAVEN_CLI_OPTS clean deploy release:prepare release:perform
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /usr/share/maven
Java version: 17.0.2, vendor: Oracle Corporation, runtime: /usr/local/openjdk-17
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.104-linuxkit", arch: "aarch64", family: "unix"
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.gfs:phoenix >---------------------------
[INFO] Building Project Phoenix - Base 1.11
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # phoenix ---
[INFO] Deleting /builds/gfalco77/phoenix/target
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.8:prepare-agent (default) # phoenix ---
[INFO] argLine set to -javaagent:/builds/gfalco77/phoenix/.m2/repository/org/jacoco/org.jacoco.agent/0.8.8/org.jacoco.agent-0.8.8-runtime.jar=destfile=/builds/gfalco77/phoenix/target/jacoco.exec
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.7:repackage (repackage) # phoenix ---
[INFO]
[INFO] --- maven-failsafe-plugin:3.0.0-M6:integration-test (default) # phoenix ---
[INFO] No tests to run.
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.8:report (report) # phoenix ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- maven-failsafe-plugin:3.0.0-M6:verify (default) # phoenix ---
[INFO] Failsafe report directory: /builds/gfalco77/phoenix/target/failsafe-reports
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # phoenix ---
[INFO] Installing /builds/gfalco77/phoenix/pom.xml to /builds/gfalco77/phoenix/.m2/repository/com/gfs/phoenix/1.11/phoenix-1.11.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) # phoenix ---
[INFO] Uploading to gitlab-maven: https://gitlab.com/api/v4/projects/36116501/packages/maven/com/gfs/phoenix/1.11/phoenix-1.11.pom
[INFO] Uploaded to gitlab-maven: https://gitlab.com/api/v4/projects/36116501/packages/maven/com/gfs/phoenix/1.11/phoenix-1.11.pom (6.5 kB at 2.2 kB/s)
[INFO] Downloading from gitlab-maven: https://gitlab.com/api/v4/projects/36116501/packages/maven/com/gfs/phoenix/maven-metadata.xml
[INFO] Downloaded from gitlab-maven: https://gitlab.com/api/v4/projects/36116501/packages/maven/com/gfs/phoenix/maven-metadata.xml (361 B at 334 B/s)
[INFO] Uploading to gitlab-maven: https://gitlab.com/api/v4/projects/36116501/packages/maven/com/gfs/phoenix/maven-metadata.xml
[INFO] Uploaded to gitlab-maven: https://gitlab.com/api/v4/projects/36116501/packages/maven/com/gfs/phoenix/maven-metadata.xml (361 B at 111 B/s)
[INFO]
[INFO] --------------------------< com.gfs:phoenix >---------------------------
[INFO] Building Project Phoenix - Base 1.11
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-release-plugin:3.0.0-M5:prepare (default-cli) # phoenix ---
[INFO] phase verify-release-configuration
[INFO] starting prepare goal, composed of 17 phases: check-poms, scm-check-modifications, check-dependency-snapshots, create-backup-poms, map-release-versions, input-variables, map-development-versions, rewrite-poms-for-release, generate-release-poms, run-preparation-goals, scm-commit-release, scm-tag, rewrite-poms-for-development, remove-release-poms, run-completion-goals, scm-commit-development, end-release
[INFO] [prepare] 1/17 check-poms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.246 s
[INFO] Finished at: 2022-07-13T16:57:18Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M5:prepare (default-cli) on project phoenix: You don't have a SNAPSHOT project in the reactor projects list. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M5:prepare (default-cli) on project phoenix: You don't have a SNAPSHOT project in the reactor projects list.
The third and last pipeline is
[maven-release-plugin] prepare for next development iteration [skip ci] which is Skipped..
Does anybody know what it should happen, why does it complain on the snapshot?
Thanks
Basically, if not that error you would run in infinite loop :) The release:prepare performs the following steps:
Check that there are no uncommitted changes in the sources
Check that there are no SNAPSHOT dependencies
Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
Transform the SCM information in the POM to include the final destination of the tag
Run the project tests (preparation goals) against the modified POMs to confirm everything is in working order
Commit the modified POMs
Tag the code in the SCM with a version name (this will be prompted for)
Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)
Eventually run completion goal(s) against the project (since 2.2)
Commit the modified POMs
So, upon completion of your CI pipeline you are getting two new commits into master branch:
[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release XXX
which in turn triggers your CI pipeline again, you just need to disable pipeline triggering for specific CI_COMMIT_MESSAGE (or setup scmReleaseCommitComment, which actually looks not so good as well as scmDevelopmentCommitComment)
UPD.
I have revised your release pipeline I can definitely say everything you are doing is wrong. The main problem is you are trying to implement release pipeline relying on suggestions from internet (e.g. what you have provided looks very similar to https://forum.gitlab.com/t/getting-mvn-release-to-work-with-gitlab-ci/4904) instead of basing on best practices and common sense...
what is the purpose of the following code snippet?
stages:
- build
- release
...
build-job:
image: $MAVEN_IMAGE
stage: build
script:
- echo "Building $MODULE"
- mvn clean package -B $MAVEN_CLI_OPTS
...
release-job:
stage: release
...
script:
- echo "Creating the release"
- mvn $MAVEN_CLI_OPTS clean deploy release:prepare release:perform
mvn package performs compile, test and package
mvn deploy performs compile, test, package, verify and deploy
release:prepare by default performs mvn clean verify
so, in your release pipeline you perform compile and test three times, and verify two times, which actually sounds good for your SaaS provider: more resources you consume - more money you spend.
following code snippet:
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- apt-get update -qq
- apt-get install -qq git
- git config --global user.email "hidden"
- git config --global user.name "hidden"
actually assumes you supposed to create your own docker images which contains jdk, maven, ssh, git and other toolchain stuff.
following code snippet:
before_script:
...
- git checkout -B "$CI_COMMIT_REF_NAME"
reveals that Gitlab is neither CI nor CD, the question is: what commit your release is based on? The answer is: on something after my commit :)
I have a spring boot gradle app which I could run successfully on my PC by doing:
heroku local
It can also deploy on heroku successfully when I go:
git push heroku master
This is my result:
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 596 bytes | 0 bytes/s, done.
Total 9 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/heroku/heroku-buildpack-gradle... done
remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: WARNING: The Gradle buildpack is currently in Beta.
remote: -----> executing ./gradlew build
remote: :compileJavaNote: Some input files use unchecked or unsafe operations.
remote: Note: Recompile with -Xlint:unchecked for details.
remote:
remote: :processResources
remote: :classes
remote: :jar
remote: :bootRepackage
remote: :assemble
remote: :compileTestJava UP-TO-DATE
remote: :processTestResources UP-TO-DATE
remote: :testClasses UP-TO-DATE
remote: :test UP-TO-DATE
remote: :check UP-TO-DATE
remote: :build
remote:
remote: BUILD SUCCESSFUL
remote:
remote: Total time: 11.935 secs
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing... done, 72.3MB
remote: -----> Launching... done, v9
remote: https://myapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/myapp.git
6326429..291326d master -> master
But when I try to access it on heroku, it crashes. The heroku logs says this:
2015-12-11T17:05:46.096985+00:00 heroku[api]: Deploy 291326d by xxx#gmail.com
2015-12-11T17:05:46.097021+00:00 heroku[api]: Release v9 created by xxx#gmail.com
2015-12-11T17:05:46.378258+00:00 heroku[slug-compiler]: Slug compilation started
2015-12-11T17:05:46.378269+00:00 heroku[slug-compiler]: Slug compilation finished
2015-12-11T17:05:46.755655+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-11T17:05:53.121398+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=5000 -jar build/libs/myapp.jar`
2015-12-11T17:05:54.260741+00:00 app[web.1]: Error: Unable to access jarfile build/libs/myapp.jar
2015-12-11T17:05:54.784064+00:00 heroku[web.1]: State changed from starting to crashed
2015-12-11T17:05:54.773714+00:00 heroku[web.1]: Process exited with status 1
2015-12-11T17:05:54.788248+00:00 heroku[web.1]: State changed from crashed to starting
Why is it Unable to access jarfile build/libs/myapp.jar ?
When I navigate to that folder on my local PC, the jarfile is there.
I'm running out of ideas on how to solve this.
You don't need to modify your stage task for that.
In your gradle.build file, make sure to give a name to your built artifact like this.
jar {
baseName = 'app'
version = '0.0.1'
}
With that been done, and the following in Procfile, it should just run fine.
web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/app-0.0.1.jar
I found that if name is not explicitly defined, heroku seems to name the artifact something like build-{buildNumber}.jar and no wonder it will never find the app.jar.
Also, if not set already, the build pack needs to be set.
heroku config:set GRADLE_TASK="build"
I eventually found a very helpful thread here: Running Spring app built with gradle on Heroku
Which helped me with my problem - this thread seems to be more detail than Heroku's official guide.
You must add the following code to your build.gradle file:
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)
clean << {
project.file('app.jar').delete()
}
Then, point your Procfile to the app.jar:
web: java $JAVA_OPTS -jar app.jar
According to the documentation:
The Gradle buildpack will automatically detect the use of the Spring Boot and Ratpack web frameworks.
The web command should be overridden only if needed. If you're using Spring Boot, you shouldn't need to specify a Procfile at all.
Delete it, and get your app running without further configuration.
A simpler solution:
I was also encountering the same error and it was a serious waste of time for me. Unlike the ones here, I solved the problem as follows.
First of all, we need to know this.
Heroku creates a new version after each build.
For this reason, if you use a command that contains a fixed version definition in the Procfile file like build/libs/app-0.0.1-SNAPSHOT.jar, it will cause an error like this.
2022-03-02T18:19:30.797673+00:00 app[web.1]: Error: Unable to access jarfile build/libs/app-0.0.1-SNAPSHOT.jar
After the build task, Gradle creates 2 jars named app-0.0.1-SNAPSHOT.jar and app-0.0.1-SNAPSHOT-plain.jar under libs/ folder. app-0.0.1-SNAPSHOT.jar is our application including all dependencies. So I first blocked the rendering of app-0.0.1-SNAPSHOT-plain.jar as below.
jar {
enabled = false
}
Then I used the following wildcard definition in Procfile which is not affected by version changes.
web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/*.jar
The problem can also be solved in this way.
For deploying Gradle App on Heroku. Just add below lines in build.gradle file.
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)
This also in build.gradle file for running jar file.
jar {
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
manifest {
attributes(
'Main-Class': 'com.heroku.herokudemo.HerokuDemoApplication'
)
}
}
After this create a txt file named Procfile and add the following content.
web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/heroku-demo-0.0.1-SNAPSHOT.jar
I installed Leiningen on Mac OS X 10.7.2 via MacPorts:
$ lein version
Leiningen 1.6.1.1 on Java 1.6.0_29 Java HotSpot(TM) 64-Bit Server VM
I also have clojure and clojure-contrib packages installed:
$ sudo port installed clojure*
The following ports are currently installed:
clojure #1.3.0_0 (active)
clojure-contrib #1.2.0_0 (active)
To test my environment, I generated a sample helloworld project, as described here by Zef Hemel. Here is the project.clj file:
(defproject helloworld "0.1"
:dependencies [[org.clojure/clojure
"1.3.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib
"1.2.0-SNAPSHOT"]]
:main helloworld)
And here is the helloworld.clj file:
(ns helloworld
(:gen-class))
(defn -main [& args]
(println "Hello world!"))
When I try to compile this project, I get several update messages...
$ pwd
/Users/alexreynolds/helloworld
$ sudo lein compile
[INFO] snapshot org.clojure:clojure:1.3.0-master-SNAPSHOT: checking for updates from clojars
Downloading: org/clojure/clojure/1.3.0-master-SNAPSHOT/clojure-1.3.0-master-SNAPSHOT.pom from clojars
[INFO] snapshot org.clojure:clojure-contrib:1.2.0-SNAPSHOT: checking for updates from clojars
Downloading: org/clojure/clojure-contrib/1.2.0-SNAPSHOT/clojure-contrib-1.2.0-SNAPSHOT.pom from clojars
Downloading: org/clojure/clojure/1.3.0-master-SNAPSHOT/clojure-1.3.0-master-SNAPSHOT.jar from clojars
Downloading: org/clojure/clojure-contrib/1.2.0-SNAPSHOT/clojure-contrib-1.2.0-SNAPSHOT.jar from clojars
...and then a whole bunch of errors:
An error has occurred while processing the Maven artifact tasks.
Diagnosis:
Unable to resolve artifact: Missing:
----------
1) org.clojure:clojure:jar:1.3.0-master-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.3.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.3.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:jar:2.0
2) org.clojure:clojure:jar:1.3.0-master-SNAPSHOT
2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure-contrib -Dversion=1.2.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.clojure -DartifactId=clojure-contrib -Dversion=1.2.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:jar:2.0
2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT
----------
2 required artifacts are missing.
for artifact:
org.apache.maven:super-pom:jar:2.0
from the specified remote repositories:
clojars (http://clojars.org/repo/),
central (http://repo1.maven.org/maven2)
----------
2 required artifacts are missing.
for artifact:
org.apache.maven:super-pom:jar:2.0
from the specified remote repositories:
clojars (http://clojars.org/repo/),
central (http://repo1.maven.org/maven2)
(NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$script_opt.invoke(main.clj:270)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at clojure.lang.Var.invoke(Var.java:377)
at clojure.lang.AFn.applyToHelper(AFn.java:172)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: Unable to resolve artifact: Missing:
----------
1) org.clojure:clojure:jar:1.3.0-master-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.3.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.clojure -DartifactId=clojure -Dversion=1.3.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:jar:2.0
2) org.clojure:clojure:jar:1.3.0-master-SNAPSHOT
2) org.clojure:clojure-contrib:jar:1.2.0-SNAPSHOT
Try downloading the file manually from the project website.
...
----------
2 required artifacts are missing.
for artifact:
org.apache.maven:super-pom:jar:2.0
from the specified remote repositories:
clojars (http://clojars.org/repo/),
central (http://repo1.maven.org/maven2)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:324)
at org.apache.maven.artifact.ant.DependenciesTask.doExecute(DependenciesTask.java:170)
... 38 more
I have tried to self-install:
$ sudo lein self-install
Downloading Leiningen now...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9161k 100 9161k 0 0 1889k 0 0:00:04 0:00:04 --:--:-- 2580k
But on the second attempt to compile, I get the same warnings and errors.
What should I try in order to fix this? Thanks for your advice.
SNAPSHOT releases are typically deployed to separate maven repositories. Recent versions of Leiningen don't include Clojure snapshot repositories in the default list of repositories.
Unless you have a good reason to use SNAPSHOT dependencies, you should list stable versions in project.clj instead:
(defproject helloworld "0.1"
:dependencies [[org.clojure/clojure "1.3.0"]]
:main helloworld)
(I removed clojure-contrib since version 1.2.0 isn't compatible with clojure 1.3 and your sample project isn't using it anyway.)
I'm trying to use Maven release plugin 2.0 to tag the version and hopefully deploy the resulting jar to the repository.
I got stuck at release:prepare, getting this cryptic error:
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "svn --non-interactive commit --file C:\Users\ME~1\AppData\Local\Temp\maven-scm-950614965.commit --targets C:\Users\ME~1\AppData\Local\Temp\maven-scm-35306-targets"
[INFO] Working directory: c:\workspace\release-test-trunk
[INFO] Tagging release with the label release-test-1.3.0...
[INFO] Executing: cmd.exe /X /C "svn --non-interactive copy --file C:\Users\ME~1\AppData\Local\Temp\maven-scm-829250416.commit --revision 1885 http://myserver/myproject/sandbox/release-test/trunk http://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0"
[INFO] Working directory: c:\workspace\release-test-trunk
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: OPTIONS of 'http://myserver/myproject/sandbox/release-test': 200 OK (http://myserver)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 seconds
[INFO] Finished at: Tue Aug 24 19:31:55 GMT 2010
[INFO] Final Memory: 14M/56M
[INFO] ------------------------------------------------------------------------
The tag folder does exist and is empty
I executed the command mvn clean release:clean release:prepare to be sure have a fresh run
Every time I got the error I executed mvn release:rollback to have everything back to normal
It doesn't seem to be a credentials problem, the pom file is effectively commited with the -SNAPSHOT removed and the scm information switched to the tag folder.
The strange part is I don't understand how the pom file is commited since I did not specify any credentials neither in the pom nor in the settings.xml file located in maven local install
I saw many people having a similar issue but with the folder already exist error message. Mine doesn't tell me what the error is precisely.
Do you have any ideas ?
Many thanks.
EDIT:
#Colin
If I browse svn://myserver/myproject/sandbox/release-test using tortoise svn for example it works fine. However if I type http://myserver/myproject/sandbox/release-test in Firefox the page is not found.
Also I think it should be ok since the pom file gets commited before trying to create the tag.
My scm section in the pom file :
<scm>
<connection>scm:svn:http://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0</connection>
<developerConnection>scm:svn:http://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0</developerConnection>
<url>http://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0</url>
</scm>
I tried removing the "http:" but that didn't work.
The problem isn't really maven here. It's more about svn itself. Maven stops its operation when svn send this error message :
svn: OPTIONS of 'http://myserver/myproject/sandbox/release-test': 200 OK (http://myserver)
Are you absolutly sure about the http://myserver/myproject/sandbox/release-test adress ?
If http://myserver/myproject/sandbox/release-test doesn't exists svn won't commit anything. Just replace the http:// by svn://
<scm>
<connection>scm:svn:svn://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0</connection>
<developerConnection>scm:svn:svn://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0</developerConnection>
<url>svn://myserver/myproject/sandbox/release-test/tags/release-test-1.3.0</url>
</scm>
Links :
svnforum.org
An SVN error (200 OK) when checking out from my online repo
Tortoise svn Subversion Update Error
I'm attempting to run the mvn release:prepare goal and it's hanging after the push. Any idea what I could be doing wrong?
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESSFUL
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 8 seconds
[INFO] [INFO] Finished at: Tue Jul 13 23:54:59 PDT 2010
[INFO] [INFO] Final Memory: 55M/294M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\Users\TAYLOR~1\AppData\Local\Temp\maven-scm-1932347225.commit pom.xml"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: C:\development\taylor\my-app
[INFO] Executing: cmd.exe /X /C "git push git#github.com:tleese22/my-app.git master:master"
[INFO] Working directory: C:\development\taylor\my-app
>>>> hangs here <<<<
Below is the SCM section of my pom.xml:
<scm>
<connection>scm:git:git://github.com/tleese22/my-app.git</connection>
<developerConnection>scm:git:git#github.com:tleese22/my-app.git</developerConnection>
<url>http://github.com/tleese22/my-app</url>
</scm>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
Below is my .git/config:
[core]
repositoryformatversion = 0
filemode = true
logallrefupdates = true
bare = false
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "origin"]
url = git#github.com:tleese22/my-app.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = git#github.com:tleese22/my-app.git
Here's the result of git show origin:
$ git remote show origin
Enter passphrase for key '/c/Users/Taylor Leese/.ssh/id_rsa':
* remote origin
Fetch URL: git#github.com:tleese22/my-app.git
Push URL: git#github.com:tleese22/my-app.git
HEAD branch: master
Remote branches:
gh-pages new (next fetch will store in remotes/origin)
master new (next fetch will store in remotes/origin)
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
$ git status
# On branch master
nothing to commit (working directory clean)
I have run into the same problem and I traced this to the fact that git is requiring a passphrase, but Maven has no way to specify an appropriate passphrase, so the process essentially hangs. Note that this problem is limited to Windows.
The solution is to run ssh-agent. This can be found in C:\Program Files (x86)\Git\bin\. After you run it, it outputs some environment variables that you need to set. For example:
SSH_AUTH_SOCK=/tmp/ssh-LhiYjP7924/agent.7924; export SSH_AUTH_SOCK;
SSH_AGENT_PID=2792; export SSH_AGENT_PID;
echo Agent pid 2792;
So, you need to place these in your environment:
C:\> set SSH_AUTH_SOCK=/tmp/ssh-LhiYjP7924/agent.7924
C:\> set SSH_AGENT_PID=2792
Then, you will need to add a passphrase for your particular key file. Generally, if you issued a command like git fetch origin master for your project, you will get a passphrase prompt like: Enter passphrase for key '/c/Users/Anthony Whitford/.ssh/id_rsa' -- that is the file that you need to register with the agent. So, the command is:
C:\> ssh-add "/c/Users/Anthony Whitford/.ssh/id_rsa"
It will prompt you for a passphrase, so enter it. You should see an Identity added message. Now, the agent knows the passphrase so that you will not be prompted to specify it anymore.
If you have multiple instances of command prompts, make sure that each command prompt has the appropriate SSH_AUTH_SOCK and SSH_AGENT_PID environment variables set. You can validate that this is working by running a command like ssh -v git#github.com and if you DO NOT get prompted for a passphrase, it is working!
Note that when you logoff, the ssh-agent will shut down and so when you log back in or restart your computer, you will need to repeat these steps. My understanding is that your passphrase is stored in memory, not persisted to disk, for security reasons.
The mvn release:prepare goal always runs in non-interactive mode, so you can't enter the ssh passphrase git is waiting for while pushing to the remote repository.
You can use an SSH agent to manage that, but if this problem only appears during the release process, there is another solution : preparing the release locally, and pushing the tag afterwards.
For this you have to use version 2.1+ of maven-release-plugin that comes with the pushChanges parameter.
mvn -DpushChanges=false release:prepare
By the way, your tag is created into your local GIT repository and you can then push it to the remote repository as usual, with a git push command.
This method is useful for Eclipse users because Eclipse comes with an embedded ssh-agent but this agent is not used by maven while performing a release:prepare, even when using eGit.
Considering the source of git builtin-push.c, that means that somehow, no remote are defined for the local Git repo used by the maven script.
static int do_push(const char *repo, int flags)
{
int i, errs;
struct remote *remote = remote_get(repo);
const char **url;
int url_nr;
if (!remote) {
if (repo)
die("bad repository '%s'", repo);
die("No destination configured to push to.");
}
As illustrated by this blog post, the maven config is not the all story.
~/foo/mikeci-archetype-springmvc-webapp$ git remote add origin git#github.com:amleggett/mikeci-archetype-springmvc-webapp.git
A remote add is still required, before specifying the maven scm parameters:
Updating the POM
For Maven to function effectively, you should always ensure that you include project VCS information in your POM file.
Now that we’ve added the archetype to a Git repository we can include the appropriate <scm> configuration:
<scm>
<connection>
scm:git:ssh://github.com/amleggett/${artifactId}.git
</connection>
<developerConnection>
scm:git:ssh://git#github.com/amleggett/${artifactId}.git
</developerConnection>
<url>
http://github.com/amleggett/${artifactId}
</url>
</scm>
The same blog post adds:
It’s important to understand the meaning of each of the child elements of <scm>.
The <connection> element defines a read-only url and
the <developerConnection> element a read+write url.
For both of these elements the url must adhere to the following convention:
scm:<scm implementation>:<scm implementation-specific path>
Finally, the <url> element content should point to a browsable location and for me this is the GitHub repository home page. Note that in all cases, I’m using an interpolated value which is my project artifactId.
One handy tip is that you can verify this configuration by using the maven-scm-plugin.
This plugin offers ‘vendor’ independent access to common VCS commands by offering a set of command mappings for the configured VCS. The validate goal should confirm all is well:
~/foo/mikeci-archetype-springmvc-webapp$ mvn scm:validate
[INFO] Preparing scm:validate
[INFO] No goals needed for project - skipping
[INFO] [scm:validate {execution: default-cli}]
[INFO] connectionUrl scm connection string is valid.
[INFO] project.scm.connection scm connection string is valid.
[INFO] project.scm.developerConnection scm connection string is valid.
[INFO] --------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
These are the exact sequence of commands I followed to get rid of this error
C:\Program Files (x86)\Git\bin>bash
bash-3.1$ eval 'ssh-agent -s'
SSH_AUTH_SOCK=/tmp/ssh-ZARFN11804/agent.11804; export SSH_AUTH_SOCK;
SSH_AGENT_PID=10284; export SSH_AGENT_PID;
echo Agent pid 10284;
bash-3.1$ exec ssh-agent bash
bash-3.1$ ssh-add "/c/Users/idntus/.ssh/id_rsa"
Enter passphrase for /c/Users/idntus/.ssh/id_rsa:
Identity added: /c/Users/idntus/.ssh/id_rsa (/c/Users/idntus/.ssh/id_rsa)
bash-3.1$ mvn release:prepare release:perform
The only thing which worked for me was specifying GIT user name and password as maven parameters:
mvn -Dusername=jenkins -Dpassword=******** release:prepare release:perform
To hide password in Jenkins output console I installed and configured Mask Passwords Plugin.
Yet another reason it could hang is if github.com isn't in the known_hosts file. SSH will therefore hang waiting for the user to accept authenticity of the host.
To add github.com to your known hosts just do a quick SSH to it: ssh github.com. The SSH client will then ask you to confirm the authenticity of the host. Type "Yes" and it'll say that its permanently added github.com to your list of known hosts.
I had faced the same problem, I had tried many ways but got to resolved it with below steps:
1. you need check git origin
2. update your pom.xml,find scm section,
change github ssh address the `:` to '/'
before
<scm>
<connection>scm:git:ssh://git#github.com:xxx/xxxin.git</connection>
<developerConnection>scm:git:ssh://git#github.com:xxx/xxxin.git</developerConnection>
<url>https://github.com/xxx/jenkins-xxx-plugin</url>
<tag>HEAD</tag>
</scm>
then
<scm>
<connection>scm:git:ssh://git#github.com/xxx/xxxin.git</connection>
<developerConnection>scm:git:ssh://git#github.com/xxx/xxxin.git</developerConnection>
<url>https://github.com/xxx/jenkins-xxx-plugin</url>
<tag>HEAD</tag>
</scm>
3. set ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>maven.jenkins-ci.org</id> <!-- For parent 1.397 or newer; before this use id java.net-m2-repository -->
<username>your jenkins username</username>
<password>your jenkins password</password>
</server>
</servers>
4. then commit & push your changes
5. run mvn release:prepare release:perform
I had the same issue.
I tried all the above solutions and still it did not work.
That was because I was still doing one thing wrong: for the ssh commands I used git bash while for the maven command I used the command prompt. And there not all the git commands were available.
After adding the complete git bin folder to the PATH variable everything worked for me.