Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fdias-2548-maven-release-configu…
Browse files Browse the repository at this point in the history
…ration' into fdias-2560-improve-it-tests
  • Loading branch information
diasf committed Oct 8, 2024
2 parents 4c74db5 + 53a3965 commit 1859f3f
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 45 deletions.
68 changes: 46 additions & 22 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pipeline {
agent {
dockerfile {
dir 'conf/docker/jenkins-build-image'
dir 'conf/docker/jenkins-build-dockercli-image'
additionalBuildArgs '-t drodb-jenkins-build'
}
}
Expand All @@ -12,6 +12,7 @@ pipeline {
booleanParam(name: 'skipUnitTests', defaultValue: true, description: 'Set to true to skip the unit tests')
booleanParam(name: 'skipIntegrationTests', defaultValue: true, description: 'Set to true to skip the integration tests')
booleanParam(name: 'deployOverride', defaultValue: false, description: 'Set to true to perform the deployment')
choice(name: 'doRelease', choices: ['skip', 'patch', 'minor', 'major'], description: 'Perform a release of new version')
}

triggers {
Expand All @@ -25,7 +26,9 @@ pipeline {
}

environment {
ARTIFACTORY_DEPLOY=credentials('ICM_ARTIFACTORY_JENKINSCI')
/*ARTIFACTORY_DEPLOY=credentials('ICM_ARTIFACTORY_JENKINSCI')*/
ARTIFACTORY_DEPLOY=credentials('ICM_ARTIFACTORY_USER')
GITHUB_DEPLOY=credentials('DATAVERSE_GORGONA_GITHUB_DEPLOY_KEY')
DOCKER_HOST_EXT = sh(script: 'docker context ls --format "{{- if .Current -}} {{- .DockerEndpoint -}} {{- end -}}"', returnStdout: true)
.trim().replaceAll('tcp', 'https')
DOCKER_CERT_EXT = '/home/jenkins/.docker'
Expand All @@ -36,12 +39,10 @@ pipeline {

stage('Build') {
when { expression { params.skipBuild != true } }
agent {
docker {
image 'openjdk:8u342-jdk'
reuseNode true
}
}
agent { dockerfile {
dir 'conf/docker/jenkins-build-image'
reuseNode true
} }
steps {
echo 'Building dataverse.'
sh './mvnw package -DskipTests'
Expand All @@ -56,12 +57,11 @@ pipeline {

stage('Unit tests') {
when { expression { params.skipUnitTests != true } }
agent {
docker {
image 'openjdk:8u342-jdk'
reuseNode true
}
}
agent { dockerfile {
dir 'conf/docker/jenkins-build-image'
reuseNode true
} }

steps {
echo 'Executing unit tests.'
sh './mvnw test'
Expand Down Expand Up @@ -108,18 +108,42 @@ pipeline {
expression { params.deployOverride == true }
}
}
agent {
docker {
image 'openjdk:8u342-jdk'
reuseNode true
}
}
agent { dockerfile {
dir 'conf/docker/jenkins-build-image'
reuseNode true
} }

steps {
echo 'Deploying artifacts.'
sh 'env'
sh './mvnw -X deploy:deploy -s settings.xml'
sh './mvnw deploy -Pdeploy -s settings.xml'
}
}

stage('Release') {
when {
triggeredBy 'UserIdCause'
expression { params.doRelease != 'skip' }
}
agent { dockerfile {
dir 'conf/docker/jenkins-build-image'
reuseNode true
} }

environment {
GIT_SSH_COMMAND = "ssh -o StrictHostKeyChecking=no"
}
steps {
script {
sshagent(['DATAVERSE_GORGONA_GITHUB_DEPLOY_KEY']) {
echo "Creating release artifacts: ${params.doRelease}"
sh 'git config user.email "[email protected]"'
sh 'git config user.name "jenkinsci"'
sh "./release.sh ${params.doRelease}"
}
}
}
}

}
}

11 changes: 11 additions & 0 deletions conf/docker/jenkins-build-dockercli-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM docker:27.3.1-alpine3.20

RUN apk add openjdk8

RUN addgroup -g 1000 jenkins && \
adduser --uid 1000 --ingroup jenkins --no-create-home --disabled-password jenkins

RUN addgroup jenkins root
RUN addgroup jenkins docker

ENTRYPOINT []
7 changes: 2 additions & 5 deletions conf/docker/jenkins-build-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM docker:27.3.1-alpine3.20
FROM openjdk:8u342-jdk

RUN apk add openjdk8

RUN addgroup -g 1000 jenkins && \
RUN addgroup --gid 1000 jenkins && \
adduser --uid 1000 --ingroup jenkins --no-create-home --disabled-password jenkins

RUN addgroup jenkins root
RUN addgroup jenkins docker

ENTRYPOINT []
6 changes: 2 additions & 4 deletions dataverse-dist/pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</parent>

<artifactId>dataverse-dist</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions dataverse-persistence/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</parent>

<artifactId>dataverse-persistence</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions dataverse-test-common/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</parent>

<artifactId>dataverse-test-common</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions dataverse-webapp/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>dataverse-webapp</artifactId>
Expand All @@ -9,7 +8,7 @@
<parent>
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</parent>

<name>dataverse-webapp</name>
Expand Down
14 changes: 10 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
If you are doing more than bumping the version number, please read
doc/sphinx-guides/source/developers/dependencies.rst
-->
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
<packaging>pom</packaging>

<name>dataverse-parent</name>
Expand All @@ -19,7 +18,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<additionalparam>-Xdoclint:none</additionalparam>
<!-- Needed to avoid IDEA IDE compilation failures. See commits in GH #5059 -->
<compilerArgument></compilerArgument>
<compilerArgument />
<project.timezone>UTC</project.timezone>
<project.language>en</project.language>
<project.region>US</project.region>
Expand Down Expand Up @@ -1018,6 +1017,13 @@
<test.docker.executeStopOnVMShutdown>true</test.docker.executeStopOnVMShutdown>
</properties>
</profile>
<profile>
<id>deploy</id>
<properties>
<skipTests>true</skipTests>
<docker.skip>true</docker.skip>
</properties>
</profile>
<!-- TODO: Add a profile to run API tests (integration tests that end in IT.java. See conf/docker-aio/run-test-suite.sh -->
</profiles>

Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi

echo "Version to be released: ${RELEASE_FULL_VERSION}. Next development version will be set to: ${DEVELOPMENT_FULL_VERSION}."

./mvnw --batch-mode release:prepare release:perform \
./mvnw --batch-mode release:prepare release:perform -s settings.xml \
-Darguments="-DskipTests -Ddocker.skip" \
-DignoreSnapshots=true -DautoVersionSubmodules=true \
-DreleaseVersion=${RELEASE_FULL_VERSION} \
Expand Down

0 comments on commit 1859f3f

Please sign in to comment.