Skip to content

Commit 9db79e2

Browse files
Merge pull request #43 from iExecBlockchainComputing/release/7.0.2
Release/7.0.2
2 parents 34e3ad8 + 0675f4b commit 9db79e2

File tree

11 files changed

+115
-209
lines changed

11 files changed

+115
-209
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
FROM openjdk:11.0.3-jre-slim
22

3-
ARG BUILD_VERSION
3+
ARG spring_boot_jar
44

5-
# the jar file is copied from "build/docker/"
6-
# by the gradle plugin "docker"
7-
COPY iexec-result-proxy-${BUILD_VERSION}.jar iexec-result-proxy.jar
5+
RUN test -n "$spring_boot_jar"
6+
7+
COPY $spring_boot_jar iexec-result-proxy.jar
88

99
# For Spring-Boot project, use the entrypoint
1010
# below to reduce Tomcat startup time.
11-
ENTRYPOINT exec java -Djava.security.egd=file:/dev/./urandom -jar iexec-result-proxy.jar
11+
ENTRYPOINT exec java -Djava.security.egd=file:/dev/./urandom -jar iexec-result-proxy.jar

Jenkinsfile

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,11 @@
1-
pipeline {
2-
3-
agent any
4-
5-
stages {
6-
stage('Test') {
7-
steps {
8-
// withCredentials([
9-
// string(credentialsId: 'ADDRESS_SONAR', variable: 'address_sonar'),
10-
// string(credentialsId: 'SONAR_CORE_TOKEN', variable: 'core_token')]){
11-
// sh './gradlew clean test sonarqube -Dsonar.projectKey=iexec-core -Dsonar.host.url=$address_sonar -Dsonar.login=$core_token --refresh-dependencies --no-daemon'
12-
// }
13-
// junit 'build/test-results/**/*.xml'
14-
sh './gradlew clean test --refresh-dependencies --no-daemon'
15-
}
16-
}
17-
18-
stage('Build') {
19-
steps {
20-
sh './gradlew build --refresh-dependencies --no-daemon'
21-
}
22-
}
23-
24-
stage('Upload Jars') {
25-
when {
26-
anyOf{
27-
branch 'master'
28-
branch 'develop'
29-
}
30-
}
31-
steps {
32-
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'nexus', usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASSWORD']]) {
33-
sh './gradlew -PnexusUser=$NEXUS_USER -PnexusPassword=$NEXUS_PASSWORD uploadArchives --no-daemon'
34-
}
35-
}
36-
}
37-
38-
stage('Build/Upload Docker image') {
39-
when {
40-
anyOf{
41-
branch 'master'
42-
branch 'develop'
43-
}
44-
}
45-
steps {
46-
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'nexus', usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASSWORD']]) {
47-
sh './gradlew -PnexusUser=$NEXUS_USER -PnexusPassword=$NEXUS_PASSWORD pushImage --no-daemon'
48-
}
49-
}
50-
}
51-
}
52-
}
1+
@Library('[email protected]') _
2+
buildJavaProject(
3+
integrationTestsEnvVars: [],
4+
shouldPublishJars: true,
5+
shouldPublishDockerImages: true,
6+
dockerfileDir: '.',
7+
//dockerfileFilename: "Dockerfile-local",
8+
buildContext: '.',
9+
//dockerImageRepositoryName: '',
10+
preProductionVisibility: 'docker.io',
11+
productionVisibility: 'docker.io')

build.gradle

Lines changed: 43 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
plugins {
22
id 'java'
3-
id 'eclipse'
4-
id 'maven'
5-
id 'jacoco'
63
id 'org.springframework.boot' version '2.2.5.RELEASE'
74
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
8-
id 'com.palantir.docker' version '0.25.0'
9-
// id 'org.sonarqube' version '2.7'
10-
// id 'com.palantir.graal' version '0.6.0-112-gca0b727'
5+
id 'eclipse'
6+
id 'jacoco'
7+
id 'org.sonarqube' version '3.3'
8+
id 'maven-publish'
119
}
1210

1311
group = 'com.iexec.result-proxy'
1412
sourceCompatibility = 11
1513
targetCompatibility = 11
1614

1715
repositories {
16+
mavenLocal()
1817
mavenCentral()
1918
maven {
2019
url 'https://nexus.iex.ec/repository/maven-public/'
@@ -28,7 +27,6 @@ configurations {
2827
compileOnly {
2928
extendsFrom annotationProcessor
3029
}
31-
deployerJars
3230
}
3331

3432
ext {
@@ -38,7 +36,6 @@ ext {
3836
dependencies {
3937
// iexec
4038
implementation "com.iexec.common:iexec-common:${iexecCommonVersion}"
41-
// implementation files("../iexec-common/build/libs/iexec-common-${iexecCommonVersion}.jar")
4239

4340
// Web3j issues, see core build.gradle
4441
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
@@ -72,9 +69,6 @@ dependencies {
7269

7370
// expiring map
7471
implementation 'net.jodah:expiringmap:0.5.8'
75-
76-
// package cloud
77-
deployerJars 'io.packagecloud.maven.wagon:maven-packagecloud-wagon:0.0.6'
7872
}
7973

8074
dependencyManagement {
@@ -87,26 +81,24 @@ test {
8781
useJUnitPlatform()
8882
}
8983

84+
task itest {
85+
group 'Verification'
86+
description 'Runs the integration tests.'
87+
}
88+
9089
// the test coverage report is
9190
// created just before the build
92-
build.dependsOn jacocoTestReport
93-
94-
// ######################
95-
// # build meta #
96-
// ######################
97-
98-
def gitBranch = 'git name-rev --name-only HEAD'.execute().text.trim()
99-
def isMasterBranch = gitBranch == 'master'
100-
def isDevelopBranch = gitBranch == 'develop'
101-
def isSnapshotVersion = project.version.contains('SNAPSHOT')
102-
103-
def nexusUser = project.hasProperty('nexusUser') ? project.getProperty('nexusUser') : ''
104-
def nexusPassword = project.hasProperty('nexusPassword') ? project.getProperty('nexusPassword') : ''
105-
def hasNexusProperties = !nexusUser.isEmpty() && !nexusPassword.isEmpty()
106-
107-
def canUploadArchives = (isMasterBranch || isDevelopBranch ) && hasNexusProperties
108-
def canPushDockerImage = (isMasterBranch || isDevelopBranch ) && hasNexusProperties
109-
def canBuildDockerImage = isMasterBranch || isDevelopBranch || project.hasProperty('forceDockerBuild')
91+
jacoco {
92+
toolVersion = "0.8.7"
93+
}
94+
// sonarqube code coverage requires jacoco XML report
95+
jacocoTestReport {
96+
reports {
97+
xml.enabled true
98+
}
99+
}
100+
tasks.test.finalizedBy tasks.jacocoTestReport
101+
tasks.sonarqube.dependsOn tasks.jacocoTestReport
110102

111103
// ######################
112104
// # create version #
@@ -123,95 +115,32 @@ compileJava.dependsOn createVersion
123115
// # upload archive #
124116
// ######################
125117

126-
project.ext.getNexusMaven = {
127-
def nexusMavenBase = 'https://nexus.iex.ec/repository'
128-
if (isSnapshotVersion) {
129-
return nexusMavenBase + '/maven-snapshots/'
130-
} else {
131-
return nexusMavenBase + '/maven-releases/'
118+
publishing {
119+
publications {
120+
maven(MavenPublication) {
121+
artifact bootJar
122+
from components.java
123+
}
132124
}
133-
}
134-
135-
uploadArchives {
136-
enabled = canUploadArchives
137-
repositories.mavenDeployer {
138-
configuration = configurations.deployerJars
139-
repository(url: getNexusMaven()) {
140-
authentication(userName: nexusUser, password: nexusPassword)
125+
repositories {
126+
maven {
127+
credentials {
128+
username project.hasProperty('nexusUser') ? nexusUser : ''
129+
password project.hasProperty('nexusPassword') ? nexusPassword : ''
130+
}
131+
url project.hasProperty('nexusUrl') ? nexusUrl : ''
141132
}
142133
}
143134
}
144135

145-
// ######################
146-
// # docker #
147-
// ######################
148-
149-
// build, tag & push image
150-
// ./gradlew docker dockerTagDev dockerTagsPush
151-
152-
def dockerImageBaseName = 'nexus.iex.ec/iexec-result-proxy'
153-
def gitShortCommit = 'git rev-parse --short HEAD'.execute().text.trim()
154-
def dockerImageTag = isSnapshotVersion ? "${version}-${gitShortCommit}" : version
155-
156-
docker {
157-
name "${dockerImageBaseName}:${dockerImageTag}"
158-
tag 'FullTag', "${dockerImageBaseName}:${dockerImageTag}"
159-
tag 'ShortCommitTag', "${dockerImageBaseName}:${gitShortCommit}"
160-
tag 'Dev', "${dockerImageBaseName}:dev"
161-
dockerfile file('Dockerfile')
162-
files "build/libs/iexec-result-proxy-${project.version}.jar"
163-
buildArgs([BUILD_VERSION: project.version])
164-
}
165-
166-
task buildImage {
167-
enabled = canBuildDockerImage
168-
dependsOn tasks.docker
169-
}
170-
171-
// docker build
172-
tasks.docker {
173-
enabled = canBuildDockerImage
174-
}
175-
176-
task pushImage {
177-
enabled = canPushDockerImage
178-
dependsOn dockerTagsPush
179-
}
180-
181-
// docker login
182-
task dockerLogin(type: Exec) {
183-
enabled = canPushDockerImage
184-
commandLine('sh', '-c', "docker login -u ${nexusUser} -p ${nexusPassword} nexus.iex.ec")
185-
}
186-
187-
// docker logout
188-
task dockerLogout(type: Exec) {
189-
enabled = canPushDockerImage
190-
commandLine('sh', '-c', 'docker logout nexus.iex.ec')
191-
}
192-
193-
// docker push
194-
dockerTagsPush {
195-
enabled = canPushDockerImage
196-
// shouldRunAfter tasks.docker
197-
dependsOn dockerLogin
198-
finalizedBy dockerLogout
199-
}
200-
201-
afterEvaluate {
202-
// don't tag if image is not build
203-
for(t in tasks.findAll{e -> e.name.contains("dockerTag")}) {
204-
t.enabled = canBuildDockerImage
205-
}
206-
// don't push tags if canPushDockerImage == false
207-
// (dockerPushFullTag, dockerPushShortCommitTag)
208-
def dockerPushTasks = tasks.findAll{t -> t.name.contains("dockerPush")}
209-
for(t in dockerPushTasks) {
210-
t.enabled = canPushDockerImage
211-
}
212-
// don't push dev tag
213-
dockerPushDev.enabled = false
136+
ext.bootJarPath = relativePath(tasks.bootJar.outputs.files.singleFile)
137+
ext.gitShortCommit = 'git rev-parse --short=8 HEAD'.execute().text.trim()
138+
ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remote.origin.url) .git'].execute().text.trim()
214139

215-
// create :dev tag after image build
216-
buildImage.dependsOn dockerTagDev
140+
task buildImage(type: Exec) {
141+
group 'Build'
142+
description 'Builds an OCI image from a Dockerfile.'
143+
dependsOn tasks.bootJar
144+
commandLine ("sh", "-c", "docker build --build-arg spring_boot_jar=$bootJarPath -t $ociImageName:$gitShortCommit ."
145+
+ " && docker tag $ociImageName:$gitShortCommit $ociImageName:dev")
217146
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=7.0.1
1+
version=7.0.2
22
iexecCommonVersion=5.9.1

gradle/wrapper/gradle-wrapper.jar

501 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ esac
8282

8383
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
8484

85+
8586
# Determine the Java command to use to start the JVM.
8687
if [ -n "$JAVA_HOME" ] ; then
8788
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
129130
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
132134
JAVACMD=`cygpath --unix "$JAVACMD"`
133135

134136
# We build the pattern for arguments to be converted via cygpath

gradlew.bat

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
3235
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
3336
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
3437

@@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
3740

3841
set JAVA_EXE=java.exe
3942
%JAVA_EXE% -version >NUL 2>&1
40-
if "%ERRORLEVEL%" == "0" goto init
43+
if "%ERRORLEVEL%" == "0" goto execute
4144

4245
echo.
4346
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +54,7 @@ goto fail
5154
set JAVA_HOME=%JAVA_HOME:"=%
5255
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5356

54-
if exist "%JAVA_EXE%" goto init
57+
if exist "%JAVA_EXE%" goto execute
5558

5659
echo.
5760
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,28 +64,14 @@ echo location of your Java installation.
6164

6265
goto fail
6366

64-
:init
65-
@rem Get command-line arguments, handling Windows variants
66-
67-
if not "%OS%" == "Windows_NT" goto win9xME_args
68-
69-
:win9xME_args
70-
@rem Slurp the command line arguments.
71-
set CMD_LINE_ARGS=
72-
set _SKIP=2
73-
74-
:win9xME_args_slurp
75-
if "x%~1" == "x" goto execute
76-
77-
set CMD_LINE_ARGS=%*
78-
7967
:execute
8068
@rem Setup the command line
8169

8270
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
8371

72+
8473
@rem Execute Gradle
85-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
8675

8776
:end
8877
@rem End local scope for the variables with windows NT shell

0 commit comments

Comments
 (0)