Skip to content

Commit

Permalink
updated jenkinsfile on main
Browse files Browse the repository at this point in the history
  • Loading branch information
nthskyradiated committed Nov 13, 2024
1 parent a39fe3d commit f4c125c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
pipeline {
// agent { label 'jenkins-agent' }
agent any
stages {
stage('Build and Test') {
steps {
echo 'building and testing...'
nodejs(cacheLocationStrategy: workspace(), nodeJSInstallationName: 'NodeJS') {
nodejs(nodeJSInstallationName: 'NodeJS') {
// Install pnpm globally, clean cache, and install dependencies
sh 'npm install -g pnpm'
sh 'npm cache clean --force'
Expand All @@ -15,15 +16,22 @@
}

stage('Deploy') {
tools { dockerTool 'DockerInstall'}
steps {
echo 'Deploying....'
echo 'Deploying...'
withCredentials([usernamePassword(credentialsId: 'myDockerID', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'curl -fsSL https://get.docker.com -o get-docker.sh'
sh 'sudo sh get-docker.sh'
sh 'docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" https://index.docker.io/v1/'
sh 'docker build -t ${DOCKER_USERNAME}/express-typescript-api-template:v${BUILD_NUMBER} -f dockerfile .'
sh 'docker push ${DOCKER_USERNAME}/express-typescript-api-template:v${BUILD_NUMBER}'
sh 'docker build -t ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER} -f dockerfile .'
sh 'docker push ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER}'
echo 'Deployed! Proceeding to delete the built container...'
sh 'docker rmi ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER}'

}
}
}
stage('Done') {
steps {
echo 'Done!'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions original.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
sh 'curl -fsSL https://get.docker.com -o get-docker.sh'
sh 'sudo sh get-docker.sh'
sh 'docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" https://index.docker.io/v1/'
sh 'docker build -t ${DOCKER_USERNAME}/express-typescript-api-template:v${BUILD_NUMBER} -f dockerfile .'
sh 'docker push ${DOCKER_USERNAME}/express-typescript-api-template:v${BUILD_NUMBER}'
sh 'docker build -t ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER} -f dockerfile .'
sh 'docker push ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER}'
}
}
}
Expand Down

0 comments on commit f4c125c

Please sign in to comment.