Skip to content

Commit

Permalink
Merge branch 'release/1.9.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Sep 21, 2020
2 parents 05fe9de + bc17312 commit fa00113
Show file tree
Hide file tree
Showing 15 changed files with 373 additions and 108 deletions.
6 changes: 0 additions & 6 deletions .directory

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Terradue.OpenSearch.Client.sln.DotSettings.user
TestResult\.xml
*auth.txt*
.*.swp
.directory
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM debian:buster-slim

# MAINTAINER Emmanuel Mathot <[email protected]>

ENV MONO_VERSION 6.8.0.123

RUN apt-get update \
&& apt-get install -y --no-install-recommends gnupg dirmngr \
&& rm -rf /var/lib/apt/lists/* \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& gpg --batch --export --armor 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF > /etc/apt/trusted.gpg.d/mono.gpg.asc \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& apt-key list | grep Xamarin \
&& apt-get purge -y --auto-remove gnupg dirmngr

RUN echo "deb http://download.mono-project.com/repo/debian stable-buster/snapshots/$MONO_VERSION main" > /etc/apt/sources.list.d/mono-official-stable.list \
&& apt-get update \
&& apt-get install -y mono-complete \
&& rm -rf /var/lib/apt/lists/* /tmp/*

ARG OPENSEARCH_CLIENT_TGZ
COPY $OPENSEARCH_CLIENT_TGZ /tmp/$OPENSEARCH_CLIENT_TGZ
RUN cd / && tar xvzf /tmp/$OPENSEARCH_CLIENT_TGZ
107 changes: 68 additions & 39 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,63 @@ pipeline {
string(name: 'TEST_AUTH', defaultValue: '', description: 'Add &lt;name&gt;=&lt;username&gt;:&lt;password&gt; triples separated by spaces. If not specified, tests requring authentication are skipped.', )
choice(name: 'DOTNET_CONFIG', choices: "Debug\nRelease", description: 'Debug will produce symbols in the assmbly to be able to debug it at runtime. This is the recommended option for feature, hotfix testing or release candidate.<br/><strong>For publishing a release from master branch, please choose Release.</strong>', )
}
agent { node { label 'centos7-mono4' } }
agent any
stages {
stage('Init') {
stage('Build') {
agent {
docker {
image 'mono:6.8'
}
}
environment {
HOME = '$WORKSPACE'
}
steps {
sh 'sudo yum -y install rpm-build redhat-rpm-config rpmdevtools yum-utils'
sh 'mkdir -p $WORKSPACE/build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}'
sh 'cp opensearch-client.spec $WORKSPACE/build/SPECS/opensearch-client.spec'
sh 'spectool -g -R --directory $WORKSPACE/build/SOURCES $WORKSPACE/build/SPECS/opensearch-client.spec'
echo "Build .NET application"
sh "msbuild /t:build /p:Configuration=DEBUG /Restore:true"
stash includes: 'Terradue.OpenSearch.Client/bin/**', name: 'opensearch-client-build'
}
}
stage('Package') {
agent {
docker {
image 'alectolytic/rpmbuilder:centos-7'
}
}
steps {
unstash name: 'opensearch-client-build'
script {
def sdf = sh(returnStdout: true, script: 'date -u +%Y%m%dT%H%M%S').trim()
if (env.BRANCH_NAME == 'master')
env.release = env.BUILD_NUMBER
else
env.release = "SNAPSHOT" + sdf
def descriptor = readDescriptor()
env.version = descriptor.version
}
}
}
stage('Build') {
steps {
echo "Build .NET application"
sh "msbuild /t:build /p:Configuration=DEBUG /Restore:true"
sh 'cp -r Terradue.OpenSearch.Client/bin $WORKSPACE/build/SOURCES/'
sh 'mkdir -p $WORKSPACE/build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}'
sh 'mkdir -p $WORKSPACE/build/SOURCES/usr/lib/opensearch-client'
sh 'cp -r Terradue.OpenSearch.Client/bin/Debug/net4.5/* $WORKSPACE/build/SOURCES/usr/lib/opensearch-client/'
sh 'mkdir -p $WORKSPACE/build/SOURCES/usr/bin'
sh 'cp src/main/scripts/opensearch-client $WORKSPACE/build/SOURCES/usr/bin'
sh 'cp src/main/scripts/opensearch-client $WORKSPACE/build/SOURCES/'
sh 'cp -r packages $WORKSPACE/build/SOURCES/'
// temporary commnented
// sh 'ls -l $WORKSPACE/build/SOURCES/packages/terradue.metadata.earthobservation/*/content/Resources/ne_110m_land'
}
}
stage('Package') {
steps {
echo "Build package dependencies"
sh "sudo yum-builddep -y $WORKSPACE/build/SPECS/opensearch-client.spec"
sh 'cp opensearch-client.spec $WORKSPACE/build/SPECS/opensearch-client.spec'
sh 'spectool -g -R --directory $WORKSPACE/build/SOURCES $WORKSPACE/build/SPECS/opensearch-client.spec'
echo "Build package"
sh "sudo rpmbuild --define \"_topdir $WORKSPACE/build\" -ba --define '_branch ${env.BRANCH_NAME}' --define '_release ${env.release}' $WORKSPACE/build/SPECS/opensearch-client.spec"
sh "rpmbuild --define \"_topdir $WORKSPACE/build\" -ba --define '_branch ${env.BRANCH_NAME}' --define '_version ${env.version}' --define '_release ${env.release}' $WORKSPACE/build/SPECS/opensearch-client.spec"
sh "rpm -qpl $WORKSPACE/build/RPMS/*/*.rpm"
}
}
stage('Test') {
when {
expression {
return params.RUN_TESTS
}
}
steps {
sh 'echo "${params.TEST_AUTH}" > Terradue.OpenSearch.Client.Test/auth.txt'
sh 'mono packages/nunit.consolerunner/3.10.0/tools/nunit3-console.exe *.Test/bin/*/net45/*.Test.dll'
}
post {
success {
nunit(testResultsPattern: 'TestResult.xml')
}
sh 'rm -f $WORKSPACE/build/SOURCES/opensearch-client'
sh "tar -cvzf opensearch-client-${env.version}-${env.release}.tar.gz -C $WORKSPACE/build/SOURCES/ ."
archiveArtifacts artifacts: 'build/RPMS/**/*.rpm,opensearch-client-*.tar.gz', fingerprint: true
stash includes: 'opensearch-client-*.tar.gz', name: 'opensearch-client-tgz'
stash includes: 'build/RPMS/**/*.rpm', name: 'opensearch-client-rpm'
}
}
stage('Publish') {
agent { node { label 'artifactory' } }
steps {
echo 'Deploying'
unstash name: 'opensearch-client-rpm'
script {
// Obtain an Artifactory server instance, defined in Jenkins --> Manage:
def server = Artifactory.server "repository.terradue.com"
Expand All @@ -75,5 +76,33 @@ pipeline {
}
}
}
stage('Build & Publish Docker') {
steps {
unstash name: 'opensearch-client-tgz'
script {
def opensearchclienttgz = findFiles(glob: "opensearch-client-*.tar.gz")
def descriptor = readDescriptor()
def testsuite = docker.build(descriptor.docker_image_name, "--build-arg OPENSEARCH_CLIENT_TGZ=${opensearchclienttgz[0].name} .")
def mType=getTypeOfVersion(env.BRANCH_NAME)
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub-emmanuelmathot') {
testsuite.push("${mType}${descriptor.version}")
testsuite.push("${mType}latest")
}
}
}
}
}
}

def getTypeOfVersion(branchName) {

def matcher = (env.BRANCH_NAME =~ /master/)
if (matcher.matches())
return ""

return "dev"
}

def readDescriptor (){
return readYaml(file: 'build.yml')
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Title>DotNetOpenSearchClient</Title>
<Description>Generic OpenSearch Client</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>1.9.6</Version>
<Version>1.9.7</Version>
<Authors>Emmanuel Mathot</Authors>
<Company>Terradue</Company>
<RepositoryUrl>https://github.com/Terradue/DotNetOpenSearchClient</RepositoryUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public void Initialize() {

// check if url contains terradue domain
var terradueDomainPattern = new Regex(@"^.*\.terradue\.com.*");
var hasTerradueDomain = BaseUrls.Any(url => terradueDomainPattern.IsMatch(url));
var hasTerradueDomain = (BaseUrls == null ? false : BaseUrls.Any(url => terradueDomainPattern.IsMatch(url)));

// if url contains terradue.com and no credentials has been specified, check for _T2Credentials in HDFS
if ( hasTerradueDomain && NetCreds.IsEmpty() ) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Xml;
using Terradue.OpenSearch.Result;
using Terradue.ServiceModel.Ogc;

namespace Terradue.OpenSearch.Model.EarthObservation {

class CycleNumberMetadataExtractor : IMetadataExtractor {
#region IMetadataExtractor implementation

public string GetMetadata(IOpenSearchResultItem item, string specifier) {

ServiceModel.Ogc.Om20.OM_ObservationType eo = null;
var extensions = item.ElementExtensions;

foreach (var ext in extensions) {
if (ext.OuterName == "EarthObservation") {
XmlReader reader = ext.GetReader();

eo = (ServiceModel.Ogc.Om20.OM_ObservationType)OgcHelpers.DeserializeEarthObservation(reader);
}
}

if (eo != null) {
if (eo is ServiceModel.Ogc.Eop21.EarthObservationType) {
try {
return eo.procedure.Eop21EarthObservationEquipment.acquisitionParameters.AltAcquisition.cycleNumber;
} catch (Exception) {
return null;
}
}

if (eo is ServiceModel.Ogc.Eop20.EarthObservationType) {
try {
return eo.procedure.Eop20EarthObservationEquipment.acquisitionParameters.AltAcquisition.cycleNumber;
} catch (Exception) {
return null;
}
}
}

return null;
}


public string Description {
get {
return "A number representing the cycle number, if available";
}
}

#endregion
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ protected override void InitializeExtractors() {
metadataExtractors.Add("cc", new CloudCoverMetadataExtractor());
metadataExtractors.Add("sensorResolution", new SensorResolutionMetadataExtractor());
metadataExtractors.Add("vs", new VendorSpecificMetadataExtractor());
metadataExtractors.Add("instrument", new InstrumentShortNameMetadataExtractor());
metadataExtractors.Add("instrumentShortName", new InstrumentShortNameMetadataExtractor());
metadataExtractors.Add("instrumentType", new InstrumentTypeMetadataExtractor());
metadataExtractors.Add("instrumentDescription", new InstrumentDescriptionMetadataExtractor());
metadataExtractors.Add("sensor", new SensorTypeMetadataExtractor());
metadataExtractors.Add("sensorType", new SensorTypeMetadataExtractor());
metadataExtractors.Add("cycle", new CycleNumberMetadataExtractor());
metadataExtractors.Add("cycleNumber", new CycleNumberMetadataExtractor());
}

public override string Name {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Xml;
using Terradue.OpenSearch.Result;
using Terradue.ServiceModel.Ogc;

namespace Terradue.OpenSearch.Model.EarthObservation {

class InstrumentDescriptionMetadataExtractor : IMetadataExtractor {
#region IMetadataExtractor implementation

public string GetMetadata(IOpenSearchResultItem item, string specifier) {

ServiceModel.Ogc.Om20.OM_ObservationType eo = null;
var extensions = item.ElementExtensions;

foreach (var ext in extensions) {
if (ext.OuterName == "EarthObservation") {
XmlReader reader = ext.GetReader();

eo = (ServiceModel.Ogc.Om20.OM_ObservationType)OgcHelpers.DeserializeEarthObservation(reader);
}
}

if (eo != null) {
if (eo is ServiceModel.Ogc.Eop21.EarthObservationType) {
try {
return eo.procedure.Eop21EarthObservationEquipment.instrument.Instrument.description;
} catch (Exception) {
return null;
}
}

if (eo is ServiceModel.Ogc.Eop20.EarthObservationType) {
try {
return eo.procedure.Eop20EarthObservationEquipment.instrument[0].Instrument.description;
} catch (Exception) {
return null;
}
}
}

return null;
}


public string Description {
get {
return "A number representing the instrument description, if available";
}
}

#endregion
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Terradue.OpenSearch.Result;

namespace Terradue.OpenSearch.Model.EarthObservation {

class InstrumentShortNameMetadataExtractor : IMetadataExtractor {
#region IMetadataExtractor implementation

public string GetMetadata(IOpenSearchResultItem item, string specifier) {

return Terradue.Metadata.EarthObservation.OpenSearch.Extensions.EarthObservationOpenSearchResultExtensions.FindInstrumentShortName(item);
}

public string Description {
get {
return "A string identifying the instrument.";
}
}

#endregion
}


}
Loading

0 comments on commit fa00113

Please sign in to comment.