Compare commits

...

14 Commits
main ... 02_07

Author SHA1 Message Date
  Michael e06b0718d6
Update README.md 3 years ago
  Michael 23873511cb
Update WINDOWS.md 3 years ago
  Spencer Nicholls 23ded30621
Delete 02_07.md 4 years ago
  Michael 4d81617076
Update MAC_LINUX_DOCKER.md 4 years ago
  Michael 91d15c0f67
Update WINDOWS.md 4 years ago
  Michael 0919a262c1
Update README.md 4 years ago
  Michael Jenkins c0de0354bb Copy main content to README 4 years ago
  Michael 51a83ccde8
Update 02_07.md 4 years ago
  Michael Jenkins d0ac0502e6 Fix things up after merge from 02_06 4 years ago
  Michael Jenkins b0237ed86d Fix things up after swithing from 02-05 4 years ago
  Michael Jenkins 60a4365736 Add OS specific scripts for the long running job 4 years ago
  Michael Jenkins 9d15431b0f Update 02_05 4 years ago
  Michael Jenkins 6611816982 Add files for Windows and 'nix systems 4 years ago
  Michael Jenkins fc3ffef338 Add files for 02_01 4 years ago
5 changed files with 150 additions and 34 deletions
Unified View
  1. +53
    -0
      MAC_LINUX_DOCKER.md
  2. +33
    -34
      README.md
  3. +53
    -0
      WINDOWS.md
  4. +5
    -0
      long-running-job-mac-linux-docker.sh
  5. +6
    -0
      long-running-job-windows.bat

+ 53
- 0
MAC_LINUX_DOCKER.md View File

@ -0,0 +1,53 @@
# Learning Jenkins, 02-07: Run and Monitor Jobs
Use the console to create a freestyle job with one build step.
## MacOS, Linux, and Docker
If you are running Jenkins on MacOS, Linux, or Docker:
1. Select the `Execute shell` build step.
2. Enter the following for the command:
```
#!/bin/bash
for i in {1..30}; do
echo $i;
sleep 1;
done
exit 1
```
## Troubleshooting Errors
If you select the `Execute Windows batch command` build step, you will see an error similar to the following:
```
Building in workspace /var/jenkins_home/workspace/hello
[hello] $ cmd /c call /tmp/jenkins3248756842772121939.bat
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
Caused: java.io.IOException: Cannot run program "cmd" (in directory "/var/jenkins_home/workspace/hello"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at hudson.Proc$LocalProc.<init>(Proc.java:253)
at hudson.Proc$LocalProc.<init>(Proc.java:222)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:21)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:808)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:164)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:516)
at hudson.model.Run.execute(Run.java:1889)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:100)
at hudson.model.Executor.run(Executor.java:433)
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
```
This is because the program Jenkins uses with the `Execute Windows batch command` build step is not available on your system.
To fix this error, use the `Execute shell` build step as described above.

+ 33
- 34
README.md View File

@ -1,34 +1,33 @@
# Learning Jenkins
This is the repository for the LinkedIn Learning course `Learning Jenkins`. The full course is available from [LinkedIn Learning][lil-course-url].
_See the readme file in the main branch for updated instructions and information._
## Instructions
This repository has branches for each of the videos in the course. You can use the branch pop up menu in github to switch to a specific branch and take a look at the course at that stage, or you can add `/tree/BRANCH_NAME` to the URL to go to the branch you want to access.
## Branches
The branches are structured to correspond to the videos in the course. The naming convention is `CHAPTER#_MOVIE#`. As an example, the branch named `02_03` corresponds to the second chapter and the third video in that chapter.
Some branches will have a beginning and an end state. These are marked with the letters `b` for "beginning" and `e` for "end". The `b` branch contains the code as it is at the beginning of the movie. The `e` branch contains the code as it is at the end of the movie. The `main` branch holds the final state of the code when in the course.
When switching from one exercise files branch to the next after making changes to the files, you may get a message like this:
error: Your local changes to the following files would be overwritten by checkout: [files]
Please commit your changes or stash them before you switch branches.
Aborting
To resolve this issue:
Add changes to git using this command: git add .
Commit changes using this command: git commit -m "some message"
## Installing
1. To use these exercise files, you must have the following installed:
- [list of requirements for course]
2. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree.
3. [Course-specific instructions]
[0]: # (Replace these placeholder URLs with actual course URLs)
[lil-course-url]: https://www.linkedin.com/learning/
[lil-thumbnail-url]: http://
# Learning Jenkins, 02-07: Run and Monitor Jobs
Create a freestyle job with one build step.
## WINDOWS SYSTEMS
If you are running Jenkins on a Windows system:
1. Select the `Execute Windows batch command` build step
2. Enter the following for the command:
```
@echo off
for /L %%i in (1,1,30) do (
@echo %%i
@ping localhost -n 2 >NUL
)
exit /b 0
```
[Follow this link for more details on Windows](WINDOWS.md)
## MacOS, Linux, and Docker
If you are running Jenkins on MacOS, Linux, or Docker:
1. Select the `Execute shell` build step.
2. Enter the following for the command:
```
#!/bin/bash
for i in {1..30}; do
echo $i;
sleep 1;
done
```
[Follow this link for more details on MacOS, Linux, and Docker](MAC_LINUX_DOCKER.md)

+ 53
- 0
WINDOWS.md View File

@ -0,0 +1,53 @@
# Learning Jenkins, 02-07: Run and Monitor Jobs
Use the console to create a freestyle job with one build step.
## WINDOWS SYSTEMS
If you are running Jenkins on a Windows system:
1. Select the `Execute Windows batch command` build step
2. Enter the following for the command:
```
@echo off
for /L %%i in (1,1,30) do (
@echo %%i
@ping localhost -n 2 >NUL
)
exit /b 0
```
## Troubleshooting Errors
If you select the `Execute shell` build step, you will see an error similar to the following:
```
Building in workspace C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\hello-jenkins
[hello-jenkins] $ sh -xe C:\Windows\TEMP\jenkins4677419767712773799.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "sh" (in directory "C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\hello-jenkins"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:253)
at hudson.Proc$LocalProc.<init>(Proc.java:222)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:21)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:808)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:164)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:516)
at hudson.model.Run.execute(Run.java:1889)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:100)
at hudson.model.Executor.run(Executor.java:433)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
```
This is because the program Jenkins uses with the `Execute shell` build step is not available on your system.
To fix this error, use the `Execute Windows batch command` as described above.

+ 5
- 0
long-running-job-mac-linux-docker.sh View File

@ -0,0 +1,5 @@
#!/bin/bash
for i in {1..30}; do
echo $i;
sleep 1;
done

+ 6
- 0
long-running-job-windows.bat View File

@ -0,0 +1,6 @@
@echo off
for /L %%i in (1,1,30) do (
@echo %%i
@ping localhost -n 2 >NUL
)

Loading…
Cancel
Save