mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-27 09:25:49 +00:00
jenkinsfile four
This commit is contained in:
parent
8dd506c69d
commit
98ed1d3c01
4 changed files with 109 additions and 26 deletions
29
build/Jenkinsfile
vendored
29
build/Jenkinsfile
vendored
|
@ -3,9 +3,9 @@ pipeline {
|
||||||
environment {
|
environment {
|
||||||
NEXUS_VERSION = "nexus3"
|
NEXUS_VERSION = "nexus3"
|
||||||
NEXUS_PROTOCOL = "http"
|
NEXUS_PROTOCOL = "http"
|
||||||
NEXUS_URL = "172.19.0.3:8081"
|
NEXUS_URL = "172.19.0.3:8281"
|
||||||
NEXUS_REPOSITORY = "maven-nexus-repo"
|
NEXUS_REPOSITORY = "maven-snapshots"
|
||||||
NEXUS_CREDENTIAL_ID = "e6072e08-87bc-481e-9e4a-55d506546356"
|
NEXUS_CREDENTIAL_ID = "deployment"//deployment user
|
||||||
REGISTRY = "http://localhost:8281/repository/docker_snapshots/"
|
REGISTRY = "http://localhost:8281/repository/docker_snapshots/"
|
||||||
REGISTRY_CREDENTIAL = "deployment"
|
REGISTRY_CREDENTIAL = "deployment"
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage("publish to nexus") {
|
stage('publish to nexus') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps
|
// Read POM xml file using 'readMavenPom' step , this step 'readMavenPom' is included in: https://plugins.jenkins.io/pipeline-utility-steps
|
||||||
|
@ -81,33 +81,18 @@ stage("publish to nexus") {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage ('image build and load') {
|
stage('image build and load') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {}
|
||||||
pom = readMavenPom file: "pom.xml";
|
docker.build registry + ":$BUILD_NUMBER"
|
||||||
env.POM_VERSION = ${pom.version}
|
|
||||||
docker.build registry + ":$POM_VERSION"
|
|
||||||
}
|
}
|
||||||
script {
|
script {
|
||||||
docker.withRegistry( '', REGISTRY_CREDENTIAL ) {
|
docker.withRegistry( '', REGISTRY_CREDENTIAL ) {
|
||||||
dockerImage.push()
|
dockerImage.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
script {
|
|
||||||
sh "docker rmi $REGISTRY:${pom.version}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post
|
|
||||||
{
|
|
||||||
success
|
|
||||||
{
|
|
||||||
script
|
|
||||||
{
|
|
||||||
env.ARTIFACT_VERSION = $POM_VERSION
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
6
deployment/Jenkinsfile
vendored
6
deployment/Jenkinsfile
vendored
|
@ -3,9 +3,9 @@ pipeline {
|
||||||
environment {
|
environment {
|
||||||
NEXUS_VERSION = "nexus3"
|
NEXUS_VERSION = "nexus3"
|
||||||
NEXUS_PROTOCOL = "http"
|
NEXUS_PROTOCOL = "http"
|
||||||
NEXUS_URL = "172.19.0.3:8081"
|
NEXUS_URL = "172.19.0.3:8281"
|
||||||
NEXUS_REPOSITORY = "maven-nexus-repo"
|
NEXUS_REPOSITORY = "maven-snapshots"
|
||||||
NEXUS_CREDENTIAL_ID = "e6072e08-87bc-481e-9e4a-55d506546356"
|
NEXUS_CREDENTIAL_ID = "deployment"//deployment user
|
||||||
REGISTRY = "http://localhost:8281/repository/docker_snapshots/"
|
REGISTRY = "http://localhost:8281/repository/docker_snapshots/"
|
||||||
REGISTRY_CREDENTIAL = "deployment"
|
REGISTRY_CREDENTIAL = "deployment"
|
||||||
}
|
}
|
||||||
|
|
5
precommit/Jenkinsfile
vendored
5
precommit/Jenkinsfile
vendored
|
@ -6,6 +6,9 @@ pipeline {
|
||||||
triggers {
|
triggers {
|
||||||
//polls repo every 2 hours from 10am to 19pm on weekdays for changes
|
//polls repo every 2 hours from 10am to 19pm on weekdays for changes
|
||||||
pollSCM('H H(10-19)/2 * * 1-5')
|
pollSCM('H H(10-19)/2 * * 1-5')
|
||||||
|
git branch: "main", "dev" //???
|
||||||
|
credentialsId: 'azima-git-ssh', //???
|
||||||
|
url: 'git://github.com/VSAzima/spring-petclinic' //???
|
||||||
}
|
}
|
||||||
options {
|
options {
|
||||||
//reduces dick I/O, may result in losing data
|
//reduces dick I/O, may result in losing data
|
||||||
|
@ -14,7 +17,7 @@ pipeline {
|
||||||
stages {
|
stages {
|
||||||
stage('pull') {
|
stage('pull') {
|
||||||
steps {
|
steps {
|
||||||
git branch: "main",
|
git branch: "main", "dev"
|
||||||
credentialsId: 'azima-git-ssh',
|
credentialsId: 'azima-git-ssh',
|
||||||
url: 'git://github.com/VSAzima/spring-petclinic'
|
url: 'git://github.com/VSAzima/spring-petclinic'
|
||||||
}
|
}
|
||||||
|
|
95
promotion/Jenkinsfile
vendored
Normal file
95
promotion/Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
pipeline {
|
||||||
|
environment {
|
||||||
|
NEXUS_VERSION = "nexus3"
|
||||||
|
NEXUS_PROTOCOL = "http"
|
||||||
|
NEXUS_URL = "172.19.0.3:8281"
|
||||||
|
NEXUS_REPOSITORY = "maven-releases"
|
||||||
|
NEXUS_CREDENTIAL_ID = "deployment"//deployment user
|
||||||
|
REGISTRY = "http://localhost:8281/repository/docker_releases/"
|
||||||
|
REGISTRY_CREDENTIAL = "deployment"
|
||||||
|
}
|
||||||
|
triggers {
|
||||||
|
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('release') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
withCredentials([file(credentialsId: 'ngx', variable: 'ROOT_CERT'),file(credentialsId:'m2', variable: 'SETTINGS')]) {
|
||||||
|
docker.image('maven:3.8.1-jdk-8').inside("-u root --network=jenkins_default") {
|
||||||
|
sh 'cp $ROOT_CERT /usr/local/share/ca-certificates/ && update-ca-certificates && cp $SETTINGS /root/.m2'
|
||||||
|
sh 'mvn release:perform'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('version') {//change version number
|
||||||
|
script {
|
||||||
|
pom = readMavenPom file: "pom.xml";
|
||||||
|
VERSION_NUMBER = VersionNumber(versionNumberString: "${pom.version}")
|
||||||
|
currentBuild.displayName = "${VERSION_NUMBER}"
|
||||||
|
sh "ant -Dversion=${VERSION_NUMBER} build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('publish to 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"]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
error "*** File: ${artifactPath}, could not be found";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('image build and load') {
|
||||||
|
steps {
|
||||||
|
script {}
|
||||||
|
docker.build registry + ":$BUILD_NUMBER"//change version number
|
||||||
|
}
|
||||||
|
script {
|
||||||
|
docker.withRegistry( '', REGISTRY_CREDENTIAL ) {
|
||||||
|
dockerImage.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue