Skip to content
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

Jenkins: Document Jenkins setup #32

Merged
merged 1 commit into from
Jun 23, 2018

Conversation

grahamwhaley
Copy link
Contributor

We don't have an overview of how our Jenkins CI is hung
together. Add a document to both aid any new instances
being set up, and to help us if we ever need to re-create
the CI.

Fixes: #30

Signed-off-by: Graham whaley graham.whaley@intel.com

@grahamwhaley
Copy link
Contributor Author

I expect this will need a touch more work - there is probably info I have missed and stuff that @chavafg might like to add.

/cc @gnawux @Pennyzct @Weichen81 @nitkon - let me know if this helps, and what it is not telling you ;-)

@grahamwhaley grahamwhaley requested a review from chavafg June 1, 2018 14:13
Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together @grahamwhaley!

@klynnrif - ptal.

Jenkins_setup.md Outdated
Kata Containers CI operates two types of CI builds:

- PR builds. Builds are scheduled upon submission or change to a Pull Request on any
of the repositories
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing period.

@@ -0,0 +1,161 @@
# Kata Containers Jenkins CI setup
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a table of contents for easy navigation?

export ghprbTargetBranch

cd $HOME
git clone https://github.com/kata-containers/tests.git
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to clone into the proper go path otherwise .ci/jenkins_job_build.sh will check itself out again to that path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And I agree! - but, the above is how it is done today in our CI (in the QA CI anyhow - iirc, in the metrics CI I use a 'go get' if I can rather than a raw git clone).
/cc @chavafg @sboeuf for input. I will leave as is at present in this doc unless we change it in our live Jenkins.

Jenkins_setup.md Outdated
>
> The `export` of the `ghprb` variables for the Master builds is benign, as the Master
> builds do not use the GHPRB plugin. Subsequently, the `jenkins_job_build.sh` script can
> still test for the GHPRB varibles to distinguish between a PR and Master build.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: "variables".

Jenkins_setup.md Outdated

The teardown script is entered into the Jenkins Post-Build Actions dialog like:

![Jenkins Build dialog](pictures/jenkins_build.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the same pic as the build script. Do we need a new image for the teardown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

heh, have the image already - did the cut/paste but forgot to update the link ;-) Fixed.

Jenkins_setup.md Outdated

| Var | Effect |
| --------- | ---------------------------------------------------------------- |
| `WORKSPACE` | Must be set. Is set by Jenkins to point at the directory the script will use as its workspace (scratch area) |
Copy link
Contributor

Choose a reason for hiding this comment

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

Bonus points for sorting the rows ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do - I sort of put them in the order the script evaluates them. I'll sort them, but if you think they might actually be better in order-of-use, ping back here.

Jenkins_setup.md Outdated

## Experienced users

For the more experienced Jenkins user, if you are au-fait reading Jenkins xml config files
Copy link
Contributor

Choose a reason for hiding this comment

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

s/xml/XML/

Jenkins_setup.md Outdated
then you can find a backup of our Azure based Jenkins QA CI in this repository under the
[jenkins sub folder](https://github.com/kata-containers/ci/tree/master/jenkins).

## Other CIs
Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct info, but I'm not sure we need to include it? If we retain it, it may be worth explaining why we switched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc, somebody mentioned they had CI hardware available for a non-x86 arch, but it was already using an alternative CI system (perhaps Travis) - so, I think maybe we leave this for the minute, and then get the other arch CIs up, and if we all end up on Jenkins or another CI, then we can drop it again... OK?

Happy to add a couple of details on why we moved - can you remember a couple of snippets? iirc, Travis does not support nested VMs (at least not the free-to-open-source version), and semaphore?? Did we just have speed/stability/reliability issues?

Copy link

@klynnrif klynnrif left a comment

Choose a reason for hiding this comment

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

Scrubbed for grammar, structure, and flow :) Thanks!

Jenkins_setup.md Outdated
# Kata Containers Jenkins CI setup

The main Continuous Integration (CI) system for Kata Containers is [Jenkins](https://jenkins.io/).
This document gives an overview of how Kata Containers integrates with Jenkins, and
Copy link

Choose a reason for hiding this comment

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

Lines 4-6 read a little awkward to me - suggested rewrite: This document is an overview of how Kata Containers integrates with Jenkins. It also directs you to configuration information and scripts to help you set up a Kata Containers Jenkins CI system.

Jenkins_setup.md Outdated
PR builds are triggered from Jenkins using the [GitHub Pull Request Builder](https://plugins.jenkins.io/ghprb) (GHPRB)
plugin.

The GHPRB plugin is configured to be triggered via github hooks. This is the preferred method
Copy link

Choose a reason for hiding this comment

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

The GHPRB plugin is configured to trigger through GitHub hooks. ...

Jenkins_setup.md Outdated
The GHPRB plugin is configured to be triggered via github hooks. This is the preferred method
to trigger on changes (preferred to polling). The preferred method is to integrate the CIs
using the [katacontainersbot](https://github.com/katacontainersbot) user. Please discuss
your requirements with the Kata Containers team who can then discuss the appropriate changes.
Copy link

Choose a reason for hiding this comment

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

your requirements with the Kata Containers team who will then discuss the appropriate changes.

Jenkins_setup.md Outdated
using the [katacontainersbot](https://github.com/katacontainersbot) user. Please discuss
your requirements with the Kata Containers team who can then discuss the appropriate changes.

The GHPRB triggers should be set up similar to:
Copy link

Choose a reason for hiding this comment

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

Set up the GHPRB triggers similar to the following:

Jenkins_setup.md Outdated
The GHPRB triggers should be set up similar to:
![Jenkins GHPRB plugin trigger config](pictures/ghprb_trigger.png)

The GHPRB `Trigger Setup` further options should be set up similar to:
Copy link

Choose a reason for hiding this comment

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

Set up the GHPRB Trigger Setup further options similar to the following:

Jenkins_setup.md Outdated
| `WORKSPACE` | Must be set. Is set by Jenkins to point at the directory the script will use as its workspace (scratch area) |
| `ghprbTargetBranch` | Is set by the GHPRB Jenkins plugin. Is only set for PR builds, and is used with `ghprbPullId` to distinguish between PR and Master builds. |
| `ghprbPullId` | Is used in PR builds to locate the correct branch on github to pull and build. |
| `KATA_DEV_MODE` | Must not be set, or the script will not act as a CI script. KATA_DEV_MODE is a developer only option allowing the script to be run 'safely' in a development environment. |
Copy link

Choose a reason for hiding this comment

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

Must not be set, or the script does not act as a CI script. ...

Jenkins_setup.md Outdated
| `ghprbTargetBranch` | Is set by the GHPRB Jenkins plugin. Is only set for PR builds, and is used with `ghprbPullId` to distinguish between PR and Master builds. |
| `ghprbPullId` | Is used in PR builds to locate the correct branch on github to pull and build. |
| `KATA_DEV_MODE` | Must not be set, or the script will not act as a CI script. KATA_DEV_MODE is a developer only option allowing the script to be run 'safely' in a development environment. |
| `METRICS_CI` | If set, will skip running the QA tests after the install/build phases (as the tests are not required for a metrics run). |
Copy link

Choose a reason for hiding this comment

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

If set, skips running the QA tests after the install/build phases ...

Jenkins_setup.md Outdated
| `GOPATH` | Is set to the installed Go environment |
| `GOROOT` | Is set to the installed Go environment |
| `PATH` | Is modified to include ${GOPATH}/bin, /usr/local/go/bin and the 'sbin' directories. |
| `kata_repo` | Is set to the github repo name, as passed in to $1 of the script. |
Copy link

Choose a reason for hiding this comment

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

github => GitHub

Jenkins_setup.md Outdated
## Other CIs

Formerly Kata Containers, and one of its predecessors [Clear Containers](https://github.com/clearcontainers)
have used both [Travis](https://travis-ci.com/) and [SemaphoreCI](https://semaphoreci.com/)
Copy link

Choose a reason for hiding this comment

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

used both Travis and SemaphoreCI

Jenkins_setup.md Outdated

## Experienced users

For the more experienced Jenkins user, if you are au-fait reading Jenkins xml config files
Copy link

Choose a reason for hiding this comment

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

Lines 151-152 suggested rewrite: For the more experienced Jenkins user, if you are comfortable reading Jenkins xml config files, there is a backup of our Azure-based Jenkins QA CI in this repository under the

@grahamwhaley grahamwhaley force-pushed the 20180601_jenkins_info branch from 2570934 to 9cb006e Compare June 1, 2018 16:50
@jodh-intel jodh-intel mentioned this pull request Jun 4, 2018
@grahamwhaley grahamwhaley force-pushed the 20180601_jenkins_info branch from 9cb006e to b1b9c20 Compare June 4, 2018 11:13
@grahamwhaley
Copy link
Contributor Author

@klynnrif @jodh-intel - updated and pushed - please re-review.

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Nice! Just a few nits and suggestions.

lgtm

Jenkins_setup.md Outdated
The Kata Containers Jenkins CI system uses Jenkins 'Freestyle Project' build jobs
to perform its builds. Kata Containers CI operates two types of CI builds:

- PR builds. Builds are scheduled upon submission or change to a Pull Request on any
Copy link
Contributor

Choose a reason for hiding this comment

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

Not essential, but if you change the layout to something like the following:

- [PR builds](#pr-builds)

  Builds are scheduled upon submission or change to a Pull Request on any of the repositories.

.. it'll render more clearly as:

  • PR builds

    Builds are scheduled upon submission or change to a Pull Request on any of the repositories.

I also added the links to the sections.

Jenkins_setup.md Outdated
plugin.

The GHPRB plugin is configured to trigger through GitHub hooks. This is the preferred method
to trigger on changes (preferred to polling). The preferred method is to integrate the CIs
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Third mention of the word "preferred" in two lines.

Jenkins_setup.md Outdated
The GHPRB plugin is configured to trigger through GitHub hooks. This is the preferred method
to trigger on changes (preferred to polling). The preferred method is to integrate the CIs
using the [katacontainersbot](https://github.com/katacontainersbot) user. Please discuss
your requirements with the Kata Containers team who will then discuss the appropriate changes.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/then discuss/then make/ ?

Jenkins_setup.md Outdated
using the [katacontainersbot](https://github.com/katacontainersbot) user. Please discuss
your requirements with the Kata Containers team who will then discuss the appropriate changes.

Set the GHPRB triggers similar to the following:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if you made the two "Set the ..." sentences to bullets whether that would auto-indent the graphics slightly for better clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooh, testing MD changes on a branch you've already PR'd is a pain in the (fork/push) fingers :-( So, I went to have a look-see, and came across this just for you @jodh-intel :-) heh heh. The other solution involved embedded HTML, which we are not doing either... let me have a play with the bullets though...

Copy link
Contributor

Choose a reason for hiding this comment

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

That is ✨ deep magic ✨ indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bullets was the only way I could find to indent the images - but adding bullets to either the leading text or the image itself both looked a bit odd. I'll leave as is.

Jenkins_setup.md Outdated
### Master builds

Master branch builds are tracked with the Jenkins [git Source Code Management](https://plugins.jenkins.io/git)
plugin. GITScm GitHub hooks are used to trigger builds.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's pretty clear but for consistency with other docs, maybe you could take " (GITScm)" to the end of the first sentence before using that term?

Jenkins_setup.md Outdated

| Var | Effect |
| --------- | ---------------------------------------------------------------- |
| `CI` | Is set by the script (unless KATA_DEV_MODE is already set) to indicate to sub-scripts that this is a CI build. |
Copy link
Contributor

Choose a reason for hiding this comment

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

KATA_DEV_MODE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the output var section - the script doesn't modify or set KATA_DEV_MODE does it?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh - maybe the comment hasn't lined up with the correct table row. I just meant to render that variable in a fixed font:

s/unless KATA_DEV_MODE is/unless KATA_DEV_MODE is/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see - got it now. Fixed, along with the one in the previous table as well.

Jenkins_setup.md Outdated

## Experienced users

For the more experienced Jenkins user, if you are au-fait reading Jenkins XML config files
Copy link
Contributor

Choose a reason for hiding this comment

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

Italics for au-fait as it's a foreign language term. I wonder if we should replace for simplicity though?

s/au-fait/comfortable/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spoil sport.... I guess I'll change it ;-)

@grahamwhaley
Copy link
Contributor Author

Hi @jongwu.

hi @jodh-intel @grahamwhaley , where does jenkins_job_build.sh run into, in the $JENKINS_HOME or in jenkins web configure UI?
I think the steps to set up jenkins ci system in a new machine is : 1. install jenkins 2. add token and credential to connect github 3 add jobs. is that right? when to run jenkins_job_build.sh?

I think you have now figured where the script is run from - in the Build/Execute Shell section of the Jenkins FreeStyle job setup dialog?
I updated this PR a little earlier. Your list is pretty accurate. Maybe I would add an extra step:

  1. Install Jenkins
  2. Install required plugins (GHPRB for instance)
  3. Add github token (or you can do this later when configuring the FreeStyle project iirc)
  4. Create and configure a Freestyle job

If is the first time integrating Jenkins with Kata Containers then it is probably most useful to start with a single 'Master' job that is tied to the runtime repository, and then use the 'Build now' option so you can check builds are working before hooking up a live PR tracking job :-)

@grahamwhaley grahamwhaley force-pushed the 20180601_jenkins_info branch from b1b9c20 to 2edbc57 Compare June 4, 2018 15:15
@grahamwhaley
Copy link
Contributor Author

Updates applied @jodh-intel

Jenkins_setup.md Outdated
| `GOPATH` | Is set to the installed Go environment |
| `GOROOT` | Is set to the installed Go environment |
| `kata_repo` | Is set to the GitHub repo name, as passed in to $1 of the script. |
| `PATH` | Is modified to include ${GOPATH}/bin, /usr/local/go/bin and the 'sbin' directories. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could use backticks for these.

@jodh-intel
Copy link
Contributor

lgtm

@grahamwhaley grahamwhaley force-pushed the 20180601_jenkins_info branch from 2edbc57 to 9792319 Compare June 4, 2018 15:41
Copy link
Contributor

@chavafg chavafg left a comment

Choose a reason for hiding this comment

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

lgtm

This is very well documented. Thanks @grahamwhaley

Copy link

@klynnrif klynnrif left a comment

Choose a reason for hiding this comment

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

I missed one instance of GitHub with a lowercase h. That is the only additional change. Thanks!

Jenkins_setup.md Outdated
![Jenkins master setup](pictures/master_git_config.png)


### Github bandwidth and tokens
Copy link

Choose a reason for hiding this comment

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

Apologies if I missed this before: Github => GitHub

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed @klynnrif , also in the ToC :-)

Copy link

Choose a reason for hiding this comment

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

Thank you!!!

@grahamwhaley grahamwhaley force-pushed the 20180601_jenkins_info branch from 9792319 to 0f97abb Compare June 5, 2018 16:25
Copy link

@klynnrif klynnrif left a comment

Choose a reason for hiding this comment

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

lgtm - thanks!

@jodh-intel
Copy link
Contributor

So close... just one more ack needed. /me look at @kata-containers/ci ... ;)

We don't have an overview of how our Jenkins CI is hung
together. Add a document to both aid any new instances
being set up, and to help us if we ever need to re-create
the CI.

Fixes: kata-containers#30

Signed-off-by: Graham whaley <graham.whaley@intel.com>
@grahamwhaley grahamwhaley force-pushed the 20180601_jenkins_info branch from 0f97abb to 4c5f8e1 Compare June 7, 2018 08:56
@grahamwhaley
Copy link
Contributor Author

rebased to clear .gitconfig clash - and now we have the big green button.... anybody

@jodh-intel
Copy link
Contributor

Looks like we need 1 more ack?

@chavafg
Copy link
Contributor

chavafg commented Jun 23, 2018

lgtm

@chavafg chavafg merged commit 454e60a into kata-containers:master Jun 23, 2018
GabyCT pushed a commit to GabyCT/ci that referenced this pull request Feb 12, 2019
GabyCT pushed a commit to GabyCT/ci that referenced this pull request Feb 12, 2019
Apply the doc teams review changes that got missed off PR kata-containers#32.

Fixes kata-containers#34.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants