Skip to content
Open
Show file tree
Hide file tree
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
53 changes: 33 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
@Library('Shared')_
pipeline{
agent { label 'dev-server'}

stages{
stage("Code clone"){
steps{
sh "whoami"
clone("https://github.com/LondheShubham153/django-notes-app.git","main")
@Library("Shared") _

pipeline {
agent { label "vinod" }
Comment on lines +1 to +4
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify shared library configuration and agent availability.

The pipeline depends on functions from the "Shared" library (hello, docker_build, docker_push). Ensure these functions are defined in your Jenkins shared library with matching signatures. Additionally, verify that the agent label "vinod" is configured and available in your Jenkins environment.


🏁 Script executed:

#!/bin/bash
# Description: Verify Jenkinsfile syntax and check for potential issues

# Validate Jenkinsfile syntax (requires Jenkins CLI)
# Note: This checks groovy syntax structure
ast-grep --pattern 'pipeline { $$$  }' Jenkinsfile

# Search for function calls to verify they match expected shared library signatures
rg -n "@Library|hello\(\)|docker_build\(|docker_push\(" Jenkinsfile

Length of output: 186



---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Locate and verify Shared library function definitions

# Find Shared library location (typically in vars/ directory)
fd -t f -e groovy | head -20

# Search for function definitions in groovy files
rg -n "def hello\(|def docker_build\(|def docker_push\(" --type groovy

# Look for SharedLibrary or vars directory structure
fd -t d -n "vars|SharedLibrary" -o "src/vars"

Length of output: 379



---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Correct search for Shared library function definitions

# Find all groovy files in the repository
fd -t f -e groovy

# Search for function definitions (corrected rg usage)
rg -n "def (hello|docker_build|docker_push)" --type groovy

# Look for vars directory or shared library structure
find . -type d -name "vars" 2>/dev/null
find . -type d -name "*[Ss]hared*" 2>/dev/null

# Check repository root for any library configuration files
ls -la | grep -E "(build|vars|library|Jenkinsfile)"

Length of output: 211



---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Examine Jenkinsfile content and structure

# Display full Jenkinsfile content to check for syntax issues
cat Jenkinsfile

# Check for valid Groovy syntax patterns (basic validation)
rg -n "stage|steps|sh|docker" Jenkinsfile

Length of output: 1388


Fix indentation inconsistencies throughout the pipeline.

The Jenkinsfile imports an external Shared library ("Shared") that cannot be verified within this repository—you must confirm the required functions (hello, clone, docker_build, docker_push) exist and have matching signatures in your Jenkins controller configuration. The agent label "vinod" must also be verified in your Jenkins environment.

However, there are indentation issues in the current Jenkinsfile that should be corrected:

  • Line 8: steps { block under stage("Hello") is misaligned
  • Lines 9-10: script and hello() indentation inconsistent
  • Lines 17-19: clone() call and closing braces over-indented (extra spaces)
  • Lines 29-33: steps, script, and docker_push() indentation misaligned

Reformat these sections to align with Groovy pipeline conventions (consistent 4-space indentation per nesting level).

🤖 Prompt for AI Agents
In Jenkinsfile (lines 1-4, and specifically adjust blocks at lines 8-10, 17-19,
29-33): fix inconsistent indentation by using 4 spaces per nesting level
throughout the declarative pipeline; align the stage("Hello") block so "steps
{", the nested "script {", and the "hello()" call share consistent 4-space
increments, remove the extra leading spaces before the "clone()" call and its
closing braces so they align with their parent "steps" block, and reformat the
docker stage so "steps", "script", and "docker_push()" are indented consistently
by 4 spaces per level; also verify externally referenced Shared library
functions (hello, clone, docker_build, docker_push) and the agent label "vinod"
exist in your Jenkins controller configuration.


stages {
stage("Hello") {
steps {
script {
hello()
}
}
stage("Code Build"){
steps{
dockerbuild("notes-app","latest")
}
}
stage("Code") {
steps {
script {
clone("https://github.com/ajaysingh3200/django-notes-app.git","main")
}
}
}
stage("Push to DockerHub"){
steps{
dockerpush("dockerHubCreds","notes-app","latest")
stage("Build") {
steps {
script {
docker_build("notes-app","latest","ajaysingh3200")
}
}
}
stage("Deploy"){
steps{
deploy()
stage('Push to DockerHub') {
steps {
script {
docker_push("notes-app","latest","ajaysingh3200")
}
}
}
stage("Deploy") {
steps {
echo "Deploying the application"
sh "docker compose down && docker compose up -d"
}
}

}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ Install Nginx reverse proxy to make this application available

`sudo apt-get update`
`sudo apt install nginx`

##########################################################
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
django_app:
build:
context: .
image: django_app
image: "ajaysingh3200/notes-app"
container_name: "django_cont"
ports:
- "8000:8000"
Expand Down