-
-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating Adding Tools section in EXTENDING_DOCKER.adoc #607
base: main
Are you sure you want to change the base?
Changes from all commits
baa09ba
ae157d3
f947573
5b72ef6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,61 @@ See the https://github.com/jenkinsci/plugin-installation-manager-tool[Plugin Ins | |
|
||
== Adding tools | ||
|
||
NOTE: This documentation section has not been implemented yet. | ||
Please feel free to submit a pull request! | ||
To add a tool let's say `git`, you can use https://github.com/jenkinsci/configuration-as-code-plugin[Jenkins Configuration-as-Code]. To know more about tools in jenkins, see https://www.jenkins.io/doc/book/managing/tools/[Managing Tools]. | ||
|
||
To configure a tool in jenkins, you first need to install required plugins for that tool, so you can install plugins in `jenkinsfile-runner` as shown in link:#_installing_plugins[Installing Plugins] section. As `git` plugin is already present in the `jenkins/jenkinsfile-runner` docker image, so no need to install it again. | ||
|
||
*Note:* Here `git` tool is different than `git` plugin, here `git` tool is the `git` command that jenkins internally uses to clone repositories. | ||
|
||
Most of the tool plugins in jenkins has support to automatically download tool from internet and install it which can be specified in Jenkins CasC, like shown in this https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos/nodejs[example]. But If you want to manually install the tool, you can write the installation steps of the tool in the same Dockerfile (that used to install plugins), like here for `git`, the preferred method to install `git` command is with OS Package Manager. | ||
|
||
Dockerfile:: | ||
|
||
[source] | ||
---- | ||
FROM jenkins/jenkinsfile-runner | ||
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* | ||
---- | ||
|
||
Next, Creating Jenkins CasC YAML file for configuring `git` tool in jenkins. Refer to link:/demo/casc/README.md[JCasC demo] for more examples. | ||
|
||
jenkins.yaml:: | ||
|
||
[source] | ||
---- | ||
tool: | ||
git: | ||
installations: | ||
- name: git | ||
home: /usr/bin/git | ||
---- | ||
|
||
Now you can run a Jenkinsfile having `git` as a stage like given below. | ||
The following is a simple Jenkinsfile to Clone the git repositories using `git` tool. | ||
|
||
Jenkinsfile:: | ||
[source] | ||
---- | ||
pipeline { | ||
agent any | ||
stages { | ||
stage('Clone git repository') { | ||
tools {git 'git'} //optional | ||
steps { | ||
git branch: 'master', url: 'git-repo-url' | ||
} | ||
} | ||
} | ||
} | ||
---- | ||
You can then run `jenkinsfile-runner` like the following | ||
[source] | ||
---- | ||
docker run --rm -v $(pwd)/Jenkinsfile:/workspace/Jenkinsfile -v $(pwd)/jenkins.yaml:/usr/share/jenkins/ref/casc/jenkins.yaml jenkinsfile-runner:my-image | ||
---- | ||
Here `jenkinsfile-runner:my-image` is custom docker image created from above Dockerfile. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of concluding with this line, you could extend to other cases by generalising or providing a list of the names of the other tools (as we have discussed on Gitter before), which they could try using the same procedure. Otherwise it appears like this is only useful for the |
||
|
||
Same procedure can be applied to add other tools like `ant`, `maven`, `jdk`, `nodejs`, `terraform` or any other tool in `jenkinsfile-runner` docker image. | ||
|
||
== Configuring Jenkins | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe it would be better to inform the user of the perspective you are coming from throughout, so they could avoid the pitfall wherein they follow your instructions as is and would likely be getting errors due to setup config issues. For example in here, you could add that say for macOS users who would ordinarily install their
git
using Homebrew orbrew
, theirgit
path would alternatively or additionally be something like/opt/homebrew/bin/git
. As is the code would not work for some macOS and Windows users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are installing git in jenkinsfile-runner docker image which is linux based, so I think there is no need to specify the installation paths for macOS or windows users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have to explain at least something like "the jenkinsfile-runner docker image is linux-based", or people will not be aware of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the one who knows jenkins, can easily understand this, and also isn't it obvious that it is Linux based docker image for anyone using jenkinsfile-runner docker image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well we have to consider new-comers to Jenkins as well like yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you are right but see all docker images created from base images like ubuntu, centos and these are linux based and since here this is the Docker doc for jenkinsfile-runner, so I guess there is no need to mention anything like here.