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

update jenkisfiel

parent 16fab55a
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
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