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 :)
Related
Maven Sonar scanner is taking a long time to download the plugins ( [INFO] Load/download plugins (done) | time=495872ms) approx. 9 mins every time a build is triggered. Also, the cache is not working as the builds are triggered on the cloud (Azure DevOps)) with an agentless/serverless architecture. What could be solutions to reduce this time that is built faster?
[INFO] User cache: /home/vsts/.sonar/cache
[INFO] SonarQube version: 7.9.1
[INFO] Default locale: "en", source code encoding: "UTF-8"
[INFO] Load global settings
[INFO] Load global settings (done) | time=1097ms
[INFO] Server id: #####-$$xxxxx$$$
[INFO] User cache: /home/vsts/.sonar/cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=211ms
[INFO] Load/download plugins (done) | time=495872ms
[INFO] Loaded core extensions: developer-scanner
You can build a self-hosted agent to run the pipeline. So that the plugins can be cached on the local agent machine. Refer to the detailed steps here to create self-hosted agent.
You can also manually download the plugin jars with its dependencies, and include them in the code repo. Then you can install them manually in your pipeline using a script task to run below commands: See here.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
For example:
mvn install:install-file -Dfile=/plugins/sonar-maven-plugin-3.6.0.1398.jar -DgroupId=org.sonarsource.scanner.maven -DartifactId=sonar-maven-plugin -Dversion=3.6.0.1398 -Dpackaging=jar`
mvn install:install-file -Dfile=/plugins/sonar-scanner-api-2.12.0.1661.jar -DgroupId=org.sonarsource.scanner.api -DartifactId=sonar-scanner-api -Dversion=2.12.0.1661 -Dpackaging=jar
You can also try using maven-install-plugin in pom file to install the local jars. See this thread for more information.
How do I run tests on Java Maven app on Heroku. I am using autodeploy linked to a branch on Github.
The default Maven command run on Heroku is:
mvn -DskipTests clean dependency:list install
To remove the skipTests, I set the MAVEN_CUSTOM_OPTS as described on https://github.com/heroku/heroku-buildpack-java#customize-maven.
However this does not result on the tests to be run. Looking at the build log I can see:
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (java-test-compile) # myapp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M1:test (default-test) # myapp ---
[INFO] No tests to run.
Compared to running Maven locally, I can see:
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (java-test-compile) # myapp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 65 source files to ...
So it would seem there is an issue with Heroku ignoring my test resources and code.
the Heroku deployment only builds and deploys your application into a Dyno.
If you need a CI environment there's Heroku CI (not free) or you can use the Azure GitHub pipelines (free for GitHub projects)
Beppe
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.
Added
If my branch is default, maven:prepare completed successfully.
/Added
I have maven project in Idea. Using mercurial.
I have created branch "MAVEN_RELEASE" to try to release it with maven-release-plugin. And got the following error. Please follow the hg push line. Is cause of the problem is AVEN_RELEASE (no first letter)?
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 02:16 min
[INFO] [INFO] Finished at: 2016-05-12T17:53:53+06:00
[INFO] [INFO] Final Memory: 63M/216M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] EXECUTING: cmd.exe /X /C "hg branch"
[INFO] EXECUTING: cmd.exe /X /C "hg outgoing"
[WARNING] A different branch than AVEN_RELEASE was found in outgoing changes, branch name was MAVEN_RELEASE. Only local branch named AVEN_RELEASE will be pushed.
[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin] prepare release sea-bni-1.0.5" C:\EA\IdeaProjects\sea-eclipse\pom.xml C:\EA\IdeaProjects\sea-eclipse\jnlp-apps\pom.xml C:\EA\IdeaProjects\sea-eclipse\jnlp-apps\arm-data-entry\pom.xml C:\EA\IdeaProjects\sea-eclipse\jnlp-apps\sea-print\pom.xml C:\EA\IdeaProjects\sea-eclipse\sea-web\pom.xml C:\EA\IdeaProjects\sea-eclipse\the-ear\pom.xml"
[INFO] EXECUTING: cmd.exe /X /C "hg push -rAVEN_RELEASE http://oksapp.bingo.ru/hg/sea-eclipse"
[ERROR]
EXECUTION FAILED
Execution of cmd : push failed with exit code: 255.
Working directory was:
C:\EA\IdeaProjects\sea-eclipse
Your Hg installation seems to be valid and complete.
Hg version: 3.5.2 (OK)
Second question, please:
2) Should I do deploy action before doing maven release prepeare, perform?
Should be resolved in maven-scm-plugin version 1.9.5, but I have no luck using it... https://issues.apache.org/jira/browse/SCM-682
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