Commit 04b9d8e3 authored by Serdar TURKEL's avatar Serdar TURKEL

feat: jenkins implemented

parent 6f053334
pipeline {
agent {
label 'master'
}
tools {
maven "Maven 3.6.0"
}
environment {
// This can be nexus3 or nexus2
NEXUS_VERSION = "nexus3"
// This can be http or https
NEXUS_PROTOCOL = "http"
// Where your Nexus is running
NEXUS_URL = "nexus.inity.com.tr:8081"
// Repository where we will upload the artifact
NEXUS_REPOSITORY = "inity"
// Jenkins credential id to authenticate to Nexus OSS
NEXUS_CREDENTIAL_ID = "nexus-credential"
}
stages {
stage('Build') {
steps {
sh 'mvn dependency:tree -Dverbose -B -DskipTests clean package'
}
}
stage("Nexus") {
steps {
script {
// Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps
pom = readMavenPom file: "pom.xml";
// Find built artifact under target folder
filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
// Print some info from the artifact found
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
// Extract the path from the File found
artifactPath = filesByGlob[0].path;
// Assign to a boolean response verifying If the artifact name exists
artifactExists = fileExists artifactPath;
if(artifactExists) {
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
version: pom.version,
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
// Artifact generated such as .jar, .ear and .war files.
[artifactId: pom.artifactId,classifier: '',file: artifactPath,type: pom.packaging],
// Lets upload the pom.xml file for additional information for Transitive dependencies
[artifactId: pom.artifactId,classifier: '',file: "pom.xml",type: "pom"]
]
);
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
version: "latest",
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
// Artifact generated such as .jar, .ear and .war files.
[artifactId: pom.artifactId,classifier: '',file: artifactPath,type: pom.packaging],
// Lets upload the pom.xml file for additional information for Transitive dependencies
[artifactId: pom.artifactId,classifier: '',file: "pom.xml",type: "pom"]
]
);
} else {
error "*** File: ${artifactPath}, could not be found";
}
}
}
}
}
}
\ No newline at end of file
# git clone http://gitlab.inity.com.tr/ertansinik/tamb.git
# docker login localhost:5000 -uadmin -padmin
mvn dependency:tree -Dverbose -B -DskipTests clean package
cp target/*.jar ./
docker-compose build
sudo docker run -d -it --net=host --restart=always springtemplate:latest
sudo docker run -d -it --net=host -p 8080:8080 --restart=always --name springtemplate springtemplate:latest
version: '3'
services:
apprest:
image: springtemplate:latest
build:
context: ./
dockerfile: Dockerfile
volumes:
- /tmp
ports:
- "8080:8080"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment