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
7b60daa4
Commit
7b60daa4
authored
Jun 16, 2022
by
Josh Steinberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added dockerfile and jenkins step for docker image to nexus
parent
4ac5c351
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
46 deletions
+73
-46
Jenkinsfile
Jenkinsfile
+73
-46
No files found.
Jenkinsfile
View file @
7b60daa4
pipeline
{
agent
any
agent
{
kubernetes
{
//cloud 'kubernetes'
defaultContainer
'kaniko'
yaml
'''
kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:v1.6.0-debug
imagePullPolicy: Always
command:
- sleep
args:
- 99d
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'
}
...
...
@@ -38,55 +67,53 @@ pipeline {
}
}
}
stage
(
"Pulbish 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
(
"Publish Docker Image 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"
;
}
container
(
name:
'kaniko'
,
shell:
'/busybox/sh'
){
sh
"pwd"
sh
"ls"
sh
'''#!/busybox/sh
/kaniko/executor -f `pwd`/Dockerfile `pwd` --insecure --skip-tls-verify --cache=true --destination=10.20.3.15:8081/jenkins-docker/hello-world:latest'
'''
}
}
}
stage
(
'Build App and Make Image'
)
{
steps
{
echo
'Building App, Making Image and Pushing Image'
container
(
name:
'kaniko'
,
shell:
'/busybox/sh'
)
{
dir
(
"inventory-backend"
){
sh
"pwd"
sh
"ls"
sh
'''#!/busybox/sh
/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=nexus.mynisum.com:2376/ascend-kafka/ascend2-inventory-backend:latest
'''
}
}
}
}
}
}
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