Commit 672bcfdb authored by Asad ullah khan's avatar Asad ullah khan

update jenkisfiel

parent 16fab55a
updateGitlabCommitStatus name: 'Jenkins', state: 'pending'
pipeline { pipeline {
environment { agent {
imageRepo = "asadullahkhan/poc-backend" kubernetes {
registryCredential = 'docker' //cloud 'kubernetes'
dockerImage = '' yaml """
} apiVersion: v1
agent any kind: Pod
stages { metadata:
stage('Cloning Git') { name: kaniko
steps { spec:
git([url: 'https://github.com/AsadUkh/app-code-backend.git', branch: 'master']) containers:
updateGitlabCommitStatus name: "Jenkins", state: "running" - name: kaniko
sh "echo Source bracnh is ${gitlabSourceBranch}" 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"
stage('Build application') { volumeMounts:
steps { - name: kaniko-secret
sh "npm install" mountPath: /kaniko/.docker
} restartPolicy: Never
} volumes:
stage('Building Docker image') { - name: kaniko-secret
steps{ secret:
script { secretName: dockercred
dockerImage = docker.build("$imageRepo:${env.BUILD_ID}") items:
} - key: .dockerconfigjson
} path: config.json
"""
} }
stage('Push Image to Docker Hub') {
steps{
script {
dockerImage.push()
}
}
}
} }
post { // stages {
always { // stage('Build with Kaniko') {
script { // steps {
try { // git 'https://github.com/prabhatsharma/sample-microservice'
echo "Helloworl integration with gitla" // container(name: 'kaniko') {
} // sh '''
catch(Exception ex) { // /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
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
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
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
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