Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hello-world-spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josh Steinberg
hello-world-spring-boot
Commits
9a396936
Commit
9a396936
authored
Jun 16, 2022
by
Josh Steinberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update dockerfile and jenkinsfile
parent
7b60daa4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
56 deletions
+48
-56
Dockerfile
Dockerfile
+8
-8
Jenkinsfile
Jenkinsfile
+40
-48
No files found.
Dockerfile
View file @
9a396936
FROM
maven:3.6.0-jdk-11-slim AS TEMP_BUILD_IMAGE
#
FROM maven:3.6.0-jdk-11-slim AS TEMP_BUILD_IMAGE
# RUN gradle build || return 0
COPY
src /home/app/src
COPY
pom.xml /home/app
RUN
mvn
-f
/home/app/pom.xml clean package
#
#
RUN gradle build || return 0
#
COPY src /home/app/src
#
COPY pom.xml /home/app
#
RUN mvn -f /home/app/pom.xml clean package
# actual container
FROM
openjdk:11-jre-slim
COPY
--from=TEMP_BUILD_IMAGE /home/app/
target/spring-boot-complete-0.0.1-SNAPSHOT.jar /usr/local/lib/hello-world.jar
FROM
amazoncorretto:11-alpine-jdk
COPY
target/spring-boot-complete-0.0.1-SNAPSHOT.jar /usr/local/lib/hello-world.jar
EXPOSE
808
0
EXPOSE
808
2
ENTRYPOINT
["java","-jar","/usr/local/lib/hello-world.jar"]
\ No newline at end of file
Jenkinsfile
View file @
9a396936
pipeline
{
agent
{
agent
{
kubernetes
{
//cloud 'kubernetes'
defaultContainer
'kaniko'
...
...
@@ -17,18 +17,9 @@ pipeline {
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /kaniko/.docker
volumes:
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: regcred
items:
- key: .dockerconfigjson
path: config.json
'''
}
}
tools
{
maven
'maven'
}
...
...
@@ -67,43 +58,44 @@ pipeline {
}
}
}
// stage("Pulbish to Nexus"){
// steps{
// script{
// pom = readMavenPom file: "pom.xml";
// filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
// echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
// artifactPath = filesByGlob[0].path;
// 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: [
// [artifactId: pom.artifactId,
// classifier: '',
// file: artifactPath,
// type: pom.packaging],
// [artifactId: pom.artifactId,
// classifier: '',
// file: "pom.xml",
// type: "pom"]
// ]
// );
// } else {
// error "*** File: ${artifactPath}, could not be found";
// }
// }
// }
// }
stage
(
"Publish Docker Image to Nexus"
){
stage
(
"Pulbish to Nexus"
){
steps
{
script
{
pom
=
readMavenPom
file:
"pom.xml"
;
filesByGlob
=
findFiles
(
glob:
"target/*.${pom.packaging}"
);
echo
"${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
artifactPath
=
filesByGlob
[
0
].
path
;
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:
[
[
artifactId:
pom
.
artifactId
,
classifier:
''
,
file:
artifactPath
,
type:
pom
.
packaging
],
[
artifactId:
pom
.
artifactId
,
classifier:
''
,
file:
"pom.xml"
,
type:
"pom"
]
]
);
}
else
{
error
"*** File: ${artifactPath}, could not be found"
;
}
}
}
}
stage
(
"Pull Artifact and Build Container"
){
steps
{
container
(
name:
'kaniko'
,
shell:
'/busybox/sh'
){
sh
"pwd"
sh
"ls"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment