Deploy SNAPSHOT version - get the (timestamped) version number - maven

If I deploy an artifact to a Maven repository with version number 1.0.0-SNAPSHOT, it will get an internal version number of the form 1.0.0-21321323-2 (timestamp and number). How can I find out this version number?

When deploying an artifact to Artifactory you get a JSON response which includes the URI of the deployed artifact. You can use that to get the timestamp version. For example:
{
"repo" : "libs-snapshot-local",
"path" : "/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar",
"created" : "2016-02-05T22:30:00.624+02:00",
"createdBy" : "admin",
"downloadUri" : "http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar",
"mimeType" : "application/java-archive",
"size" : "67966",
"checksums" : {
"sha1" : "f608440d5aadc64a5ef50320a385aeae49abd58a",
"md5" : "a844a8ab8226ff25854127480f3cfeac"
},
"originalChecksums" : {
},
"uri" : "http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar"
}
Another option is using the latest version search REST API which allows searching for the latest artifact version by groupId and artifactId.
For example:
$ curl -uadmin:password "http://localhost:8081/artifactory/api/search/latestVersion?g=org.jfrog.buildinfo&a=build-info-extractor-maven3&v=2.5.4-SNAPSHOT&repos=libs-snapshot-local"
2.5.4-20160205.203000-1

Related

Ext Direct and Spring upgrade

I have upgraded Ext Direct from 1.3.2 to 1.8.0 and Spring Framework from 4.2.6.RELEASE to 5.1.7.RELEASE
After that actions in REMOTING_API becomes empty
Ext.app.REMOTING_API = {
"url" : "/ui/.../services/router",
"namespace" : "Ext....",
"type" : "remoting",
"actions" : { }
};
I'm stuck on this, any help will be appreciated.

Elasticsearch with Yii 2.0: Error: Elasticsearch request failed: 7 - Failed to connect to ##.##.##.### port 9200: Connection refused

I have Elasticsearch properly configured on my server. I can do everything from the command line using cURL. I can even connect to it using cURL from a PHP script outside Yii. However, I can't seem to get it to work from within Yii 2.0.
In my config, I have:
'elasticsearch' => [
'class' => 'yii\elasticsearch\Connection',
'nodes' => [
['http_address' => 'localhost:9200'],
// configure more hosts if you have a cluster
],
],
But when I try to do a simple query in Yii, I get this error. Note how it's using my server ip address rather than 'localhost' or '172.0.0.1'. Note: I've hashed out my ip address for sercurity.
Elasticsearch Database Exception – yii\elasticsearch\Exception
Elasticsearch request failed: 7 - Failed to connect to ##.##.##.### port 9200: Connection refused
Error Info: Array
(
[requestMethod] => GET
[requestUrl] => http://##.##.##.###:9200/profiles/profile/_search
[requestBody] => {"size":100,"query":{"match_all":{}}}
[responseHeaders] => Array
(
)
[responseBody] =>
)
I was able to fix this error by updating the version of Elasticsearch to something > 1.3.0 as this is the minimum requirement for YIISOFT/YII2-ELASTICSEARCH
run curl -X GET 'http://127.0.0.1:9200' to check what version you are running.
First follow this steps to download elastic search.
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.2.tar.gz
mkdir es
tar -xf elasticsearch-1.5.2.tar.gz -C es
cd es
./bin/elasticsearch
Then you must be able to access to localhost:9200 and get something like this below :
{
"name" : "Sigyn",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.4.0",
"build_hash" : "ce9f0c7394dee074091dd1bc4e9469251181fc55",
"build_timestamp" : "2016-08-29T09:14:17Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}
Then secondly,follow instruction in https://github.com/yiisoft/yii2-elasticsearch. Then you are done

Why are my Spring Data repositories not found if moved into another package of a Spring Boot application?

I created a new project in Eclipse from these helpful spring examples (Import Getting Started Content). It is called "gs-accessing-data-rest-complete"
Reference and full Code can be found: spring-guides/gs-accessing-data-rest
When leaving the example unchanged, except using WAR instead of JAR packaging, everything works well. When calling $ curl http://localhost:8080/, I'll get an exposure of usable resources.
$ curl http://localhost:8080/
{
"_links" : {
"people" : {
"href" : "http://localhost:8080/name{?page,size,sort}",
"templated" : true
},
"profile" : {
"href" : "http://localhost:8080/alps"
}
}
But when moving the PersonRepository into another package, e.g. myRepos via Eclipse's Refactor-->Move command, a resource is not accessible anymore.
The response from curl is then:
$ curl http://localhost:8080/
{
"_links" : {
"profile" : {
"href" : "http://localhost:8080/alps"
}
}
}
As far as I understood, Spring scans for Repositories automatically. Because the main class uses #SpringBootApplication annotation, everything should be found by spring itself.
What am I missing? Do I have to add some special XML configuration file or add another Configuration Class somewhere? Or do I have to update application.properties in order to sth.?
Perhaps somebody has some useful experiences, she or he might share with me. Thank you.
Try specifying the base package to use when scanning for repositories by using this annotation on your config class: #EnableJpaRepositories(basePackages = "your.base.repository.package")

Gradle dependencyManagement

I am migrating Maven project to Gradle. I needed manage dependencies so tryed resolutionStrategy like so:
def dependencyVersions = [
'org.slf4j:slf4j-api' : '1.7.2',
'javax.inject:javax.inject' : '1',
'com.google.code.findbugs:annotations' : '2.0.1',
'com.typesafe:config' : '1.0.0',
'ch.qos.logback:logback-classic' : '1.0.9',
'com.google.guava:guava' : '14.0',
'com.google.inject:guice' : '3.0',
'com.google.inject.extensions:guice-multibindings' : '3.0',
'com.google.code.gson:gson' : '2.2.2',
'joda-time:joda-time' : '2.1',
'com.thoughtworks.paranamer:paranamer' : '2.5.2',
'org.codehaus.groovy:groovy-all' : '2.0.6',
'commons-validator:commons-validator': '1.4.0',
'org.apache.shiro:shiro-core' : '1.2.1',
'junit:junit-dep' : '4.10',
'org.mockito:mockito-core' : '1.9.5',
'org.hamcrest:hamcrest-core': '1.3',
'org.hamcrest:hamcrest-library': '1.3',
'org.unitils:unitils-core': '3.3'
]
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
def version = dependencyVersions["$details.requested.group:$details.requested.name"]
if (version != null)
details.useVersion version
}
}
}
but now when I try to Gradle install (into local Maven repository) I am getting this error:
Execution failed for task ':counter-module:install'.
Could not publish configuration 'archives'
Unable to initialize POM pom-default.xml: Failed to validate POM for project lt.counter at /home/workspace/counter/counter-module/build/poms/pom-default.xml
I still may be missing an aspect of your problem, but I just noticed something in the docs.
// force certain versions of dependencies (including transitive)
// *append new forced modules:
force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4'
// *replace existing forced modules with new ones:
forcedModules = ['asm:asm-all:3.3.1']
It seems like you could do the following:
def dependencyVersions = [
'org.slf4j:slf4j-api' : '1.7.2',
'javax.inject:javax.inject' : '1',
'com.google.code.findbugs:annotations' : '2.0.1',
'com.typesafe:config' : '1.0.0',
'ch.qos.logback:logback-classic' : '1.0.9',
'com.google.guava:guava' : '14.0',
'com.google.inject:guice' : '3.0',
'com.google.inject.extensions:guice-multibindings' : '3.0',
'com.google.code.gson:gson' : '2.2.2',
'joda-time:joda-time' : '2.1',
'com.thoughtworks.paranamer:paranamer' : '2.5.2',
'org.codehaus.groovy:groovy-all' : '2.0.6',
'commons-validator:commons-validator': '1.4.0',
'org.apache.shiro:shiro-core' : '1.2.1',
'junit:junit-dep' : '4.10',
'org.mockito:mockito-core' : '1.9.5',
'org.hamcrest:hamcrest-core': '1.3',
'org.hamcrest:hamcrest-library': '1.3',
'org.unitils:unitils-core': '3.3'
]
force dependencyVersion.collect {k, v -> "$k:$v"}
To my eyes, it looks like this would accomplish two principles.
Give users a nice map notation to use when they want to play nice and add a dep with your predetermined version.
Force them to use the predetermined version any time they try to get tricky.
The default resolution strategy for Gradle is to use the newest version, so version N will be used; version N-1 will not.
You do not tell us which version of Gradle you are using and the full structure of your project(s). Are you doing a multi-project build?
Also I don't understand your custom resolution strategy - why would the version ever be null?
-- edit --
The newest version is the default resolution strategy, so the highest version encountered will be used.
Maybe have a look at Gradle's examples on custom resolution strategies, such as forcing a particular version.

How do I pass UserData to a Beanstalk instance with CloudFormation

I need the application server, which is beanstalk instances, to do some actions upon startup and I thought of running a bash script passed to the instance with the UserData property which is available to regular EC2 instances.
I've found several example CloudFormation templates which does this with regular EC2 instances, but no example with Beanstalk. I've tried to add this to the properties field for the application:
"MyApp" : {
"Type" : "AWS::ElasticBeanstalk::Application",
"Properties" : {
"Description" : "MyApp description",
"ApplicationVersions" : [{
...
}],
"UserData" : {
"Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"touch /tmp/userdata_sucess\n"
]]
}},
...
I also tried to add to the environment part:
"MyAppEnv" : {
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "MyApp" },
"Description" : "MyApp environment description",
"UserData" : {
"Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"touch /tmp/userdata_sucess\n"
]]
}},
"TemplateName" : "MyAppConfiguration",
"VersionLabel" : "First Cloud version"
}
},
In both cases this resulted in failure when trying to create the stack. Does anyone know if it is possible to pass UserData to a Beanstalk instance using CloudFormation. If so - can you provide an example.
If you want to have all the advantages that Beanstalk offers - like not having to patch the OS which Amazon does for you - this isn't possible. One option is to create a custom AMI where you include the needed scripts, but then you must manage the OS yourself with security patches. Read more here.
You can do this with .ebextensions, see Amazon docs.
An example:
packages:
yum:
bison: []
libpcap-devel: []
libpcap: "1.4.0"
golang: "1.13.4"
git: []
commands:
20_show_info_pkgs:
env:
GOPATH: /usr/local/gocode
PATH: $PATH:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/usr/local/bin
ignoreErrors: true
command: |
ls -l /usr/local /usr/local/g*
env
yum list bison libpcap-devel libpcap golang git
which git
which go
git --version
go version
goreplay version
true

Resources