Jenkins Buildserver remove prefix with wildcard - java

In the last time I try to use Jenkins to build my Maven artifacts.
I have a Maven project called Imladria. It has some modules like ImladriaCore, ImladriaLibrary and ImladriaDatabase (examples, there are some more).
I have a Maven project in my Jenkins build server. Jenkins fetches all sources from my Gitlab server and builds all artifacts. After building it will publish all artifacts over FTP on my server.
It publishes them with their whole prefix so i'll have this structure on my server:
/home/user/TestServer/ImladriaCore/target/...
/home/user/TestServer/ImladriaLibrary/target/...
/home/user/TestServer/ImladriaDatabase/target/...
And so on.
I want my Jenkins to publish all built .jar in the same directory. I know that I have to remove the prefix. But this would only work without the ImladriaCore, Library, ... files when they are in they target direcory. E.g.:
/home/user/TestServer/target/ImladriaCore-1.0-Snapshot.jar
/home/user/TestServer/target/ImladriaLibrary-1.0-Snapshot.jar
/home/user/TestServer/target/ImladriaDatabase-1.0-Snapshot.jar
I tried many permutations of removing **/target/ */target/ or whatever as a prefix to publish all .jar in the same directory (/home/user/TestServer/).
I always get this error:
ERROR: Exception when publishing, exception message
[Failed to remove prefix from file named [ImladriaCore/target/imladriacore-1.0-SNAPSHOT.jar].
Prefix [*/target/] must be present in all file paths]
Does anyone know which wildcard I would have to choose?
My configuration of publishing:
Publish
Server config
Thank you and Regards
- Felix

Related

quarkus dev build failes with customized outputDirectory in pom.xml of dependend module

I started with a quarkus multi maven-module project and encountered the following problem when starting quarkus in the dev mode (mvn quarkus:dev) to support hot reload for depended modules' classes:
A module "my-app" configures its' build output path via the
<project><build><outputDirectory>build</outputDirectory> in the pom.xml. The module is build successfully, and the output exists in path my-app/build instead of the default target/classes.
Then the build of another module "momsServerQuarkus", which depends on the "my-app", and which uses quarkus-maven-plugin, fails with error:
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:2.11.0.Final:dev (default-cli) on project momsServerQuarkus: Failed to run: Hot reloadable dependency de.kwsoft.moms:my-app:6.14.0-SNAPSHOT has not been compiled yet (the classes directory S:\trunk\moms\my-app\target\build does not exist)
As visible in the error message, the <outputDirectory>build</outputDirectory>is read correctly from the my-apps' pom.xml, but is appended to the default output path "target" instead of the projects root folder. I played also variables, e.g. <outputDirectory>${basedir}/build</outputDirectory>, but the variable is not resolved by the quarkus-maven-plugin.
Does anyone know how this could be solved, or whether this could be a bug?
Thank you in advance.

How to build a jar file on Azure and copy to Artifactory?

I have an Azure pipeline that is supposed to be building my java code with maven. The YAML looks like this:
steps:
- task: Maven#3
inputs:
mavenPomFile: '$(system.defaultWorkingDirectory)/<project-name>/pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
goals: 'package'
#allowBrokenSymlinks:
# Copy jar file from a source folder to a target folder
- task: CopyFiles#1
inputs:
sourceFolder: '$(system.defaultWorkingDirectory)/<project-name>/target'
contents: 'filename.jar'
targetFolder: '$(Build.ArtifactStagingDirectory)'
cleanTargetFolder: false # Optional
overWrite: true # Optional
I was expecting there to be a jar file in the /target but nothing shows up there. Then, since there is no jar file created, the copy to Artifactory doesn't work either. The pipeline runs without error. Azure docs are clear as mud.
I'm new to Azure and Artifactory so please keep it simple if you can help!
The easiest and most recommended way is to use the Artifactory Azure DevOps extension.
The extension uses the JFrog CLI to build and upload your Maven JARs to Artifactory.
After downloading and installation of the extension, you can configure your pipeline in 2 steps
Configure Artifactory service connection.
In your pipeline, configure Artifactory Maven build. To Make it upload the JARs to Artifactory, please run the Maven install goal instead of package.
For more information see:
Extension documentation
Webinar
General information about the JFrog CLI.
Have you tried using Wild Card for fetching the jar?
Example:
-task: CopyFiles#1
inputs:
sourceFolder: '$(system.defaultWorkingDirectory)//target'
contents: *.jar
targetFolder: '$(Build.ArtifactStagingDirectory)'
cleanTargetFolder: false # Optional
overWrite: true # Optional

Akka: unable to read configuration in karaf

I am using Akka actors for Remote communication in karaf.
When I deploy the jar file generated after compiling using maven, I get the following error:
Exception in thread "Thread-113"
com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:176)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:246)
at akka.actor.ActorSystem$Settings.(ActorSystem.scala:168)
at akka.actor.ActorSystemImpl.(ActorSystem.scala:522)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:142)
at akka.actor.ActorSystem$.apply(ActorSystem.scala:119)
at org.opendaylight.com.test.rem$$anon$1.run(rem.scala:19)
I even added Maven shade plugin in the pom file which was suggested in other answers, but adding the plugin makes all the karaf features to change to ''Resolved'' state. The configuration file for akka is in the classpath too. As of my knowledge, the akka configuration file is not being read at all, as I got the same exception even after removing the configuration file.
This error is most often caused by combining multiple Akka jars into a single super-jar and not handling the reference.conf files correctly. The reference.conf file in each of the Akka module jar-files needs to be concatenated into a single file in the super jar.
Follow the instructions in the docs here: https://doc.akka.io/docs/akka/current/scala/general/configuration.html#when-using-jarjar-onejar-assembly-or-any-jar-bundler
And then verify that the jar-file you use when running has the contents of all those reference.conf files concatenated into a single file.

JMS: activemq-version.properties is not available

I am trying to establish a JMS connection. In connectionFactory.createContext, I get an error that the ActiveMQ version loader reports that a properties file is missing:
Caused by: java.lang.RuntimeException: activemq-version.properties is not available
at org.apache.activemq.artemis.utils.VersionLoader.getVersion(VersionLoader.java:87)
I am running the project from Eclipse - so it's most likely an eclipse classpath issue, but I can't find which library is missing.
Full stacktrace:
javax.jms.JMSRuntimeException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.JmsExceptionUtils.convertToRuntimeException(JmsExceptionUtils.java:88)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:262)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContex t(ActiveMQConnectionFactory.java:248)
at at.cone.health.dispo.online.DispoServerFacadeImpl$JMSReceiverThread.run(DispoServerFacadeImpl.java:109)
Caused by: javax.jms.JMSException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:727)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:255)
... 2 more
Caused by: java.lang.RuntimeException: activemq-version.properties is not available
at org.apache.activemq.artemis.utils.VersionLoader.getVersion(VersionLoader.java:87)
at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQClientProtocolManager.<init>(ActiveMQClientProtocolManager.java:81)
at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQClientProtocolManagerFactory.newProtocolManager(ActiveMQClientProtocolManagerFactory.java:49)
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.newProtocolManager(ServerLocatorImpl.java:575)
at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.<init>(ClientSessionFactoryImpl.java:173)
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:757)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:724)
... 3 more
The code where I try to set up the connection:
InitialContext namingContext = new InitialContext(env);
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(CONNECTION_FACTORY);
System.out.println("Got ConnectionFactory " + CONNECTION_FACTORY);
destination = (Destination) namingContext.lookup(DESTINATION);
System.out.println("Got JMS Endpoint " + DESTINATION);
final JMSContext context = connectionFactory.createContext("internal", "internal");
this.context = context;
JMSConsumer consumer = context.createConsumer(destination, "client='" + clientUID + "'", true);
// Then receive the same number of messages that were sent
The project is ANT based, so I cannot use maven dependency management. Nevertheless, the server part uses a maven build, so I have a local maven repository and an eclipse build path variable M2_REPO pointing to the .m2 directory. I tried to set up a library dependency in my eclipse project. I am running the project from eclipse, so we can - at first - ignore ANT related dependencies, and focus just on eclipse (but without maven).
I added a library dependency to the wildfly-client-all-10.0.0.Final.jar from my maven repo (using my M2_REPO variable, extended by the path). The library is correctly displayed as referenced library in the eclipse project.
I implemented a demo with same lines of codes in an eclipse maven project. Here I didn't get an exception, in the demo I was able to receive messages. So I assume it's a classpath issue.
I also searched for the missing activemq-version.properties on google and on stackoverflow, but didn't find anything related. I also didn't find a resource called activemq-version.properties, even not in the demo project (and its dependencied) where it was executed successfully.
After some more investigation, I did now identify the reason.
In the run config, I had a different classpath. This classpath remained from an elder configuration. Here, I didn't use the same jar as the maven build. The run configuration contained both the jboss-client.jar and the jboss-cli-client.jar from wildfly/bin/client directory.
This configuration was wrong, and caused an additional warning which I didn't recognize in my logs, but which was also a hint to the solution:
WARN: EJB client integration will not be available due to a problem setting up the EJB client handler
I changed it to the wildfly-client-all-10.0.0.Final.jar which is also contained in maven project runtimes, but it again didn't solve the issue.
Then I found this article: https://developer.jboss.org/thread/267824
Solution: back to the first configuration approach for the runtime config, using the JAR from wildfly\bin\client directory, but only the jboss-cli-client.jar AND NOT the jboss-client-jar.

Jenkins Repository connector Plugin Error "failed to expand tokens for [Artifact filename:ear::version]"

Can someone please help me with this error?
Jenkins version is 1.624
Plugin version is 1.1.1
failed to expand tokens for [Artifact filename:ear::version]
java.lang.NullPointerException
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.convertHudsonNonProxyToJavaNonProxy(Aether.java:151)
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.addProxySelectorIfNecessary(Aether.java:139)
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.newSession(Aether.java:183)
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.resolve(Aether.java:189)
at org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver.download(ArtifactResolver.java:129)
at org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver.perform(ArtifactResolver.java:101)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Build step 'Artifact Resolver' marked build as failure
Finished: FAILURE
Issue has been resolved....
There was a proxy nexus server setup in Jenkins
Jenkins - manage jenkins - manage plugins- advanced tab
removed the proxy server settings and defined the artifact resolver build step in the jenkins job ...worked fine
Fail on error check the box
Enable repository logging -donot check box
Target directory- leave this empty
Release update policy-always
Snapshot update policy-always
Group Id-ear file group id
Artifact Id-ear fil aritfact id
Version- can be parameterized or use "LATEST"
Extension-ear
Target file name-full ear file name
worked fine plugin 1.1.1 has no issues.

Categories

Resources