Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app-code-backend
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
1
Merge Requests
1
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
POC
app-code-backend
Commits
672bcfdb
Commit
672bcfdb
authored
Mar 13, 2022
by
Asad ullah khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update jenkisfiel
parent
16fab55a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
59 deletions
+124
-59
Jenkinsfile
Jenkinsfile
+39
-59
Jenkinsfile copy
Jenkinsfile copy
+63
-0
kaniko.yaml
kaniko.yaml
+22
-0
No files found.
Jenkinsfile
View file @
672bcfdb
updateGitlabCommitStatus
name:
'Jenkins'
,
state:
'pending'
pipeline
{
environment
{
imageRepo
=
"asadullahkhan/poc-backend"
registryCredential
=
'docker'
dockerImage
=
''
}
agent
any
stages
{
stage
(
'Cloning Git'
)
{
steps
{
git
([
url:
'https://github.com/AsadUkh/app-code-backend.git'
,
branch:
'master'
])
updateGitlabCommitStatus
name:
"Jenkins"
,
state:
"running"
sh
"echo Source bracnh is ${gitlabSourceBranch}"
}
}
stage
(
'Build application'
)
{
steps
{
sh
"npm install"
}
}
stage
(
'Building Docker image'
)
{
steps
{
script
{
dockerImage
=
docker
.
build
(
"$imageRepo:${env.BUILD_ID}"
)
}
}
}
stage
(
'Push Image to Docker Hub'
)
{
steps
{
script
{
dockerImage
.
push
()
}
}
}
}
post
{
always
{
script
{
try
{
echo
"Helloworl integration with gitla"
}
catch
(
Exception
ex
)
{
echo
"Unable to get pod name, may be no pods were created. Check previous steps for more logs. This is NOT a build error."
}
// archiveArtifacts artifacts: 'application.log'
}
}
success
{
updateGitlabCommitStatus
name:
"Jenkins"
,
state:
"success"
}
failure
{
updateGitlabCommitStatus
name:
"Jenkins"
,
state:
"failed"
}
unstable
{
updateGitlabCommitStatus
name:
"Jenkins"
,
state:
"failed"
}
}
agent
{
kubernetes
{
//cloud 'kubernetes'
yaml
"""
apiVersion: v1
kind: Pod
metadata:
name: kaniko
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:latest
args:
- "--context=https://gitlab.mynisum.com/poc/app-code-backend/"
- "--destination=asadullahkhan/kaniko-demo-backend-image:1.0"
volumeMounts:
- name: kaniko-secret
mountPath: /kaniko/.docker
restartPolicy: Never
volumes:
- name: kaniko-secret
secret:
secretName: dockercred
items:
- key: .dockerconfigjson
path: config.json
"""
}
}
// stages {
// stage('Build with Kaniko') {
// steps {
// git 'https://github.com/prabhatsharma/sample-microservice'
// container(name: 'kaniko') {
// sh '''
// /kaniko/executor --dockerfile `pwd`/Dockerfile --context `pwd` --destination=123456789498.dkr.ecr.us-west-2.amazonaws.com/sample-microservice:latest --destination=123456789498.dkr.ecr.us-west-2.amazonaws.com/sample-microservice:v$BUILD_NUMBER
// '''
// }
// }
// }
// }
}
\ No newline at end of file
Jenkinsfile copy
0 → 100644
View file @
672bcfdb
updateGitlabCommitStatus name: 'Jenkins', state: 'pending'
pipeline {
environment {
imageRepo = "asadullahkhan/poc-backend"
registryCredential = 'docker'
dockerImage = ''
}
agent any
stages {
stage('Cloning Git') {
steps {
git([url: 'https://github.com/AsadUkh/app-code-backend.git', branch: 'master'])
updateGitlabCommitStatus name: "Jenkins", state: "running"
sh "echo Source bracnh is ${gitlabSourceBranch}"
}
}
stage('Build application') {
steps {
sh "npm install"
}
}
stage('Building Docker image') {
steps{
script {
dockerImage = docker.build("$imageRepo:${env.BUILD_ID}")
}
}
}
stage('Push Image to Docker Hub') {
steps{
script {
dockerImage.push()
}
}
}
}
post {
always {
script {
try {
echo "Helloworl integration with gitla"
}
catch(Exception ex) {
echo "Unable to get pod name, may be no pods were created. Check previous steps for more logs. This is NOT a build error."
}
// archiveArtifacts artifacts: 'application.log'
}
}
success {
updateGitlabCommitStatus name: "Jenkins", state: "success"
}
failure {
updateGitlabCommitStatus name: "Jenkins", state: "failed"
}
unstable {
updateGitlabCommitStatus name: "Jenkins", state: "failed"
}
}
}
\ No newline at end of file
kaniko.yaml
0 → 100644
View file @
672bcfdb
apiVersion
:
v1
kind
:
Pod
metadata
:
name
:
kaniko
spec
:
containers
:
-
name
:
kaniko
image
:
gcr.io/kaniko-project/executor:latest
args
:
-
"
--context=https://gitlab.mynisum.com/poc/app-code-frontend/"
-
"
--destination=asadullahkhan/kaniko-demo-image:1.0"
volumeMounts
:
-
name
:
kaniko-secret
mountPath
:
/kaniko/.docker
restartPolicy
:
Never
volumes
:
-
name
:
kaniko-secret
secret
:
secretName
:
dockercred
items
:
-
key
:
.dockerconfigjson
path
:
config.json
\ No newline at end of file
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