Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pipeline{
agent { label 'dev-server' }
agent any;

stages{
stage("Code Clone"){
steps{
echo "Code Clone Stage"
git url: "https://github.com/LondheShubham153/node-todo-cicd.git", branch: "master"
git url: "https://github.com/sharmarobin0211/node-todo-cicd.git", branch: "master"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Use credentials for repository checkout.

Hard-coding the HTTPS URL without credentials handling can fail for private repos and exposes no authentication. Consider binding Jenkins credentials or using SSH:

git credentialsId: 'github-ssh-key', url: 'git@github.com:sharmarobin0211/node-todo-cicd.git', branch: 'master'
🤖 Prompt for AI Agents
In Jenkinsfile at line 8, the git checkout uses a hard-coded HTTPS URL without
credentials, which can fail for private repositories and lacks authentication.
Replace the git step to use credentials by specifying the credentialsId for
Jenkins-managed SSH keys and switch the URL to the SSH format. This ensures
secure and authenticated access to the repository during checkout.

}
}
stage("Code Build & Test"){
Expand All @@ -14,22 +14,6 @@ pipeline{
sh "docker build -t node-app ."
}
}
stage("Push To DockerHub"){
steps{
withCredentials([usernamePassword(
credentialsId:"dockerHubCreds",
usernameVariable:"dockerHubUser",
passwordVariable:"dockerHubPass")]){
sh 'echo $dockerHubPass | docker login -u $dockerHubUser --password-stdin'
sh "docker image tag node-app:latest ${env.dockerHubUser}/node-app:latest"
sh "docker push ${env.dockerHubUser}/node-app:latest"
}
}
}
stage("Deploy"){
steps{
sh "docker compose down && docker compose up -d --build"
}
}

}
}