azure pipeline maven release - maven

I am writing my first pipeline and if some one can please help. I have issue with creating a release version jar.
2 pom.xml (1 in master branch and 1 in development branch )
master branch pom.xml has release plugin defined
development branch pom.xml has compile and release plugin defined .
apart from that both pom.xml is same
When i run the pipeline from development branch it checkout development pom.xml and working absolutely fine like create snapshot.jar , (i use mvn clean install here )
When i run the pipeline from master branch it checkout master pom.xml and giving parent pom not solvable issue , (i use mvn release:prepare release:perform here )
[Thread-5] INFO org.apache.maven.shared.release.exec.InvokerMavenExecutor - [FATAL] Non-resolvable parent POM for com.xxxxxxxxx: com.xxxxx-parent:pom:1.0.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM # line 5, column 13
[Thread-5] INFO org.apache.maven.shared.release.exec.InvokerMavenExecutor - # ```
the strange part is when i use mvn clean install like in development in master branch code , it gives no problem but it is releasing snapshot.jar .
My release plugin has some issue , i dont know what
my goal is when running from development branch it should create snapshot.jar and when i run from master branch it should create <application>_release_version.jar .
any help much appreciated
- task: ArtifactoryMaven#2
inputs:
# mavenPomFile: '${{ parameters.layer }}/pom.xml'
# goals: 'clean install'
mavenPomFile: 'pom_azure.xml'
goals: 'release:prepare release:perform'
# options: '-U -DlocalCheckout=true -Dresume=false --batch-mode -Dtag=v1.0.0 -DreleaseVersion=1.0.0 -DdevelopmentVersion=2.0.0-SNAPSHOT Dusername=Personal%20Access%20Token -Dpassword=11c9decb81845396ecbd4bc8f09521e73077bbbf'
options: '-B -DpushChanges=false -DlocalCheckout=true -Dresume=false --batch-mode -DreleaseVersion=${{ parameters.release_ver }} -DdevelopmentVersion=${{ parameters.release_ver }}-SNAPSHOT'
artifactoryResolverService: 'xxxx'
targetResolveReleaseRepo: 'aaa-maven-virtual'
targetResolveSnapshotRepo: 'aaa-maven-virtual'
artifactoryDeployService: 'xxxx'
targetDeployReleaseRepo: 'aaa-main-maven-releases'
targetDeploySnapshotRepo: 'bbb-main-maven-snapshots'
collectBuildInfo: true
buildName: '$(Build.DefinitionName)'
buildNumber: '$(Build.BuildNumber)'
displayName: 'Maven Release'

Related

Deploying Maven project via GitHub actions fails

I'm trying to deploy a multi module project to GitHub packages but whenever Maven hits the "deploy" cycle it fails.
my GitHub action job:
release:
name: Release 🚀
# needs: test
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
repository-projects: write
packages: write
steps:
- uses: actions/checkout#v3
with:
ref: master
- uses: actions/setup-java#v3
with:
java-version: 17
distribution: adopt
cache: maven
- name: Release package
run: |
git config user.name "githubaction[bot]"
git config user.email "actions#github.com"
mvn -B release:prepare
mvn -B release:perform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
My pom files has the needed config:
<distributionManagement>
<!-- Github distribution -->
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/MYUSERNAME/${project.artifactId}</url>
</repository>
</distributionManagement>
<scm>
<developerConnection>scm:git:https://github.com/MYUSERNAME/${project.artifactId}</developerConnection>
</scm>
The prepare step goes fine but a soon as Maven tries to perform the release (and thus hits the deploy stage) I get the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project my-artifact-sub-module: Failed to deploy artifacts: Could not find artifact my-artifact-sub-module:jar:1.1.0 in github (https://maven.pkg.github.com/mathiasbosman/fs-core) -> [Help 1]
Which is bizar as right before it fails Maven logs:
[INFO] Uploading to github: https://maven.pkg.github.com/my/path/my-artifact-sub-module/1.1.0/my-artifact-sub-module-1.1.0.jar
[INFO] Uploading to github: https://maven.pkg.github.com/my/path/my-artifact-sub-module/1.1.0/my-artifact-sub-module-1.1.0.pom
The structure would be:
my-artifact (pom)
- my-artifact-sub-module (jar)
- my-artifact-sub-module-two (jar)
I tried calling mvn deploy manually in a seperate step but it gives me the same result.
The scm url apperently was wrong (missing the .git extension)
As simple as that.
The complete scm:
<scm>
<connection>scm:git:${project.scm.url}</connection>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>https://github.com/MYUSERNAME/${project.artifactId}.git</url>
<tag>HEAD</tag>
</scm>

Maven-Release with Jenkins: Skip second test run

We use Jenkins (2.150.1) together with M2 Release Plugin (0.14.0). After checkout from git we specified "Maven release build -> Release goals and options"
-Dresume=false release:prepare release:perform -DautoVersionSubmodules -Dgoals=deploy
and in the Build step we configured the maven "Goals and Options"
clean verify -U
When we start to perform a Maven release, I get asked e.g. a Release Version 1.0 and a new Version 1.1-SNAPSHOT.
Generally, everything works fine like the following way:
git clone
mvn changes versions to 1.0
mvn clean verify -U
mvn release perform
mvn changes version to 1.1-SNAPSHOT
mvn clean verify -U
mvn release perform
Question: Do you know how I can skip the second part? So maven does update to Version 1.1-SNAPSHOT but does NOT perform the following two steps?

Cannot download & install old OpenDayLight versions

I need to download an old ODL version for testing (Helium release in this case), but when I tried to build ODL with maven, it failed to download opendaylight.odlparent:odlparent:pom:1.4.7-SNAPSHOT from nexus repository (it seems old versions <3.0.4 were purged) and stopped.
Where can I download Helium ODL and run successfully?
Step to reproduce error:
git clone -b stable/helium https://github.com/opendaylight/controller.git
cd controller/
mvn clean install
[ERROR] The project org.opendaylight.controller:opendaylight-karaf-resources:[unknown-version] (/[...]/controller/opendaylight/distribution/opendaylight-karaf-resources/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for org.opendaylight.controller:commons.opendaylight:1.4.7-SNAPSHOT: Failure to find org.opendaylight.odlparent:odlparent:pom:1.4.7-SNAPSHOT in http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ was cached in the local repository, resolution will not be reattempted until the update interval of opendaylight-snapshot has elapsed or updates are forced and 'parent.relativePath' points at no local POM # org.opendaylight.controller:commons.opendaylight:1.4.7-SNAPSHOT, /[...]/controller/opendaylight/commons/opendaylight/pom.xml, line 4, column 11 -> [Help 2]
EDIT: This answer said SNAPSHOT releases had short lives, so for older versions one need to build all dependencies himself, how can I do it?
You need to do "git clone -b stable/helium ..." and build every project that the controller project depends on. For Helium I believe it's only odlparent and yangtools.

Failure to find jar in repository when I build Livy using "mvn clean package"

I am a newbie of Livy and I build Livy as the official said. The command is as follows:
git clone https://github.com/apache/incubator-livy.git
cd incubator-livy
mvn package
Then I get error as follows:
[ERROR] Plugin org.apache.maven.plugins:maven-enforcer-plugin:1.4.1 or
one of its dependencies could not be resolved: Failure to find
org.apache.maven.plugins:maven-enforcer-plugin:jar:1.4.1 in
http://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced ->`
I clean the ~/.m2/ and I use mvn -U clean package, it failed too. Could anyone help me? Thank you
Install python package as follows:
cloudpickle
requests
requests-kerberos
flake8
flaky
pytest
It will work

maven release:branch - where to perform?

I tried today to switch our release build so that it uses branches. Before my change, I just did
mvn release:prepare -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -Dtag=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION
mvn release:perform
Now I changed to use
mvn release:branch -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -DbranchName=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION -DautoVersionSubmodules=true -DbranchBase=$SVN_BRANCH_BASE -DdryRun=false -DsuppressCommitBeforeBranch=false -DremoteTagging=false -DupdateBranchVersions=true -DupdateVersionsToSnapshot=false -DupdateWorkingCopyVersions=true -DgenerateBackupPoms=false
then I checked that branch out and tried to perform a release on it. But this does not work, it tells me:
Unable to configure SCM repository: No such provider: 's'
SCM config is:
<scm>
<connection>scm:svn:https://svn2.mycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</connection>
<developerConnection>scm:svn:https://svn2.cmycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</developerConnection>
<url>https://svn2.mycompany.com:8443/svn/polyalert/branches/02_Los_1/releases/0.01.9</url>
</scm>
This url might look a bit strange, but we do not have a default layout and this is a correct branch URL.
This is done with maven 3. I´m not sure if it´s correct to do the release:perform in another location than I did the release:branch, but I don´t have a better idea, specifically because I can not set any release.properties file like it is created with release:prepare. Or would it be necessary to do the release:branch AND the release:prepare? A first try on that did not work and got the same error.
Any suggestions?
Thanks
Michael
After lots of struggle, I found the following approach working:
Ensure that your trunk has definitely correct scm info in the pom.
run mvn release:branch -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -DbranchName=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$NEXT_DEV_VERSION -DautoVersionSubmodules=true -DbranchBase=$SVN_BRANCH_BASE -DupdateWorkingCopyVersions=true.
This will create a branch in SVN where all versions are kept like they are in the trunk and will then increase version number in the trunk to $NEXT_DEV_VERSION and commit this as well. Branchbase can be set in the plugin configuration as well (in this case it can be omitted here).
checkout the new-made branch and change into the local branch dir
run mvn release:prepare -B -Dusername=$SVN_USER -Dpassword=$SVN_PASSWORD -Dtag=$RELEASE_VERSION -DreleaseVersion=$RELEASE_VERSION to update the release number in your branch to $RELEASE_VERSION (will be changed locally + commit into the branch by this single command). This command will on top create a release tag.
run mvn release:perform in your local branch dir to start the actual build. This will checkout the tag created in the previous step and build upon this code.

Resources