Tools: Jenkins Runs Commands For Me

Tools: Jenkins Runs Commands For Me

Source: Dev.to

🛠 Task Rules (IMPORTANT) ## 🧩 Step 1: Create Freestyle Job ## 🧩 Step 2: Add Shell Build Step ## ✍️ Step 3: Write This Script (Line by Line) ## Line 1 ## Line 2 ## Line 3 ## Line 4 ## Line 5 ## Line 6 ## Line 7 ## ▶️ Step 4: Run the Job ## ✅ What Should See ## 🧠 DevOps Concepts They Just Learned ## Ask them: ## ❌ Result Open Jenkins: http://localhost:9090 “What do you think will happen?” “Jenkins is stupid but honest. If a command fails, Jenkins stops everything.” Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: devops-first-script Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: devops-first-script CODE_BLOCK: devops-first-script CODE_BLOCK: echo "Hello from Jenkins" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: echo "Hello from Jenkins" CODE_BLOCK: echo "Hello from Jenkins" CODE_BLOCK: whoami Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: pwd Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: ls Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: echo "This file was created by Jenkins" > jenkins.txt Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: echo "This file was created by Jenkins" > jenkins.txt COMMAND_BLOCK: echo "This file was created by Jenkins" > jenkins.txt CODE_BLOCK: cat jenkins.txt Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: cat jenkins.txt CODE_BLOCK: cat jenkins.txt CODE_BLOCK: echo "Script completed successfully" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: echo "Script completed successfully" CODE_BLOCK: echo "Script completed successfully" CODE_BLOCK: exit 1 Enter fullscreen mode Exit fullscreen mode - Engineer runs commands manually - Forgets steps - Makes mistakes - Cannot repeat reliably - Commands are written once - Jenkins runs them the same way every time - Anyone can click Build Now - ❌ No copy–paste - ✅ Students type each line - ✅ After each line, explain why it exists - Open Jenkins: http://localhost:9090 - Click New Item - Select Freestyle project - Scroll to Build - Click Add build step - Choose Execute shell - echo prints text - Proves Jenkins can execute commands - First validation Jenkins is working - Shows which user Jenkins runs as - Important for permissions (DevOps reality) - Explains why some commands fail later - Shows where Jenkins runs - Introduces the concept of workspace - Jenkins does NOT run in your home folder - Lists files in workspace - Shows workspace starts empty - Important before cloning repos later - Jenkins creates files just like a human - Demonstrates automation creates artifacts - > redirects output into a file - Confirms file exists - Verifies Jenkins work visually - Basic troubleshooting skill - Clear log message - Professional habit in CI/CD - Helps debugging later - Click Build Now - Open Console Output - Text printed - Jenkins workspace path - File created - File content displayed - Build turns RED - Jenkins stops - No further steps run - exit 1 = failure - Jenkins trusts exit codes - This is how bad code blocks deployments