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

feat(Windows): refactor build process #1770

Merged

Conversation

lemeurherve
Copy link
Member

@lemeurherve lemeurherve commented Nov 3, 2023

Refactoring of the Windows image build like https://github.com/jenkinsci/docker-agent, https://github.com/jenkinsci/docker-inbound-agent and https://github.com/jenkinsci/docker-ssh (this last one is WIP until I found out how to fix some recalcitrant tests).

This PR allows to:

  • Keep Windows image updated (for windowsservercore-2019 image not updated #1736 & Update Jenkins version for Windows Image #1490)

  • Publish Windows images for each supported JDKs and not only JDK11 (for Publish a Windows image for each supported Java version #1774)

    • Only JDK17 (default JDK since breaking(Windows): set Java 17 as default #1773) and JDK11 (to continue providing an image as still supported), JDK21 will have to wait until tests can be parallelized as builds take between 35 and 40 minutes for both JDKs
    • Building and publishing JDK11 & JDK17 Windows images take around 10 minutes (compared to around 20 minutes for longest Linux images)
  • Get a Windows base image matching the controller image tag (for windowsservercore-2019 images use windowsservercore-1809 as base image #1775)

  • Publish a proper set of Windows image tags (for Windows Tags #1489)

    • Current tags for reference (On the 3rd of November 2023): image
    • Tags from this pull request:

      jdk17-hotspot-windowsservercore-ltsc2019 (default JDK)

      • windowsservercore-ltsc2019
      • 2.430-windowsservercore-ltsc2019
      • jdk17-hotspot-windowsservercore-ltsc2019
      • 2.430-jdk17-hotspot-windowsservercore-ltsc2019

      jdk11-hotspot-windowsservercore-ltsc2019

      • jdk11-hotspot-windowsservercore-ltsc2019,
      • 2.430-jdk11-hotspot-windowsservercore-ltsc2019
    • Windows container image tags are now properly reflecting the Windows version (see previous point), and have changed from windowsservercore-2019 to windowsservercore-ltsc2019

      • While the current tags contain "windowsservercore-2019", the current image is a 1809, not a ltsc2019:
        FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-windowsservercore-1809
      • This can understandably considered as a breaking change, let me know if you think it requires a pull request renaming and the addition of corresponding label
  • Use docker compose file to declaratively define tags and docker compose build for building, tagging and testing images, reducing script complexity

    • Ease transition to docker bake when it will be available for Windows (cf this comment: cleanup(Windows): remove unused make.ps1 parameters #1769 (comment))
    • I tried publishing images and tags with docker compose push but unfortunately this command pushes only the image of the builds, not its additional tags defined in the docker-compose file.
  • Have only one Dockerfile for every JDK versions

  • The possibility to integrate additional images for new Windows version like Windows Server Core ltsc2022 if wanted, with only a Jenkinsfile change and no time penalty (parallel builds)

    https://ci.jenkins.io/job/Packaging/job/docker/job/PR-1770/154/:

    • Combination of Windows Server Core ltsc2019 & ltsc2022 and JDK11 & JDK17 images
    • 12 minutes, skipping tests like on trusted.ci.jenkins.io, no Linux image
    • Jenkinsfile change for the additional image type:
    --- old/Jenkinsfile
    +++ new/Jenkinsfile
    @@ -1,4 +1,13 @@
     #!/usr/bin/env groovy
    +def agentSelector(String imageType) {
    +    // Image types running on a Windows Server Core 2022 agent
    +    if (imageType.contains('2022')) {
    +        return 'windows-2022'
    +    }
    +    // Remaining image types running on a Windows Server Core 2019 agent: (nanoserver|windowservercore)-(1809|2019)
    +    return 'windows-2019'
    +}
     
     def listOfProperties = []
     listOfProperties << buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '5'))
    @@ -15,11 +24,15 @@
         def builds = [:]
         def windowsImageTypes = [
             'windowsservercore-ltsc2019',
    +        'windowsservercore-ltsc2022',
         ]
        for (anImageType in windowsImageTypes) {
             def imageType = anImageType
             builds[imageType] = {
    -            nodeWithTimeout('windows-2019') {
    +            nodeWithTimeout(agentSelector(imageType)) {
  • The possibility to integrate additional images for new Windows flavor like Nanoserver if wanted, with only a Jenkinsfile change, a dedicated Dockerfile and no time penalty (parallel builds)
  • Align build process between Jenkins images

Testing done

  • Executed dry-run before and after

    Before:
    $ pwsh make.ps1 publish -DryRun  
    = PREPARE: List of jenkins4eval/jenkins images and tags to be processed:
    {
      "jdk17-hotspot-windowsservercore-2019": {
        "Tags": [
          "jdk17-hotspot-windowsservercore-2019",
          "windowsservercore-2019"
        ],
        "Folder": "17/windows/windowsservercore-2019/hotspot"
      }
    }
    Building jdk17-hotspot-windowsservercore-2019 => tag=jdk17-hotspot-windowsservercore-2019
    (dry-run) docker build -t jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-2019 17/windows/windowsservercore-2019/hotspot
    Building jdk17-hotspot-windowsservercore-2019 => tag=windowsservercore-2019
    (dry-run) docker build -t jenkins4eval/jenkins:windowsservercore-2019 17/windows/windowsservercore-2019/hotspot
    Publishing jdk17-hotspot-windowsservercore-2019 => tag=jdk17-hotspot-windowsservercore-2019
    (dry-run) docker push jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-2019
    Publishing jdk17-hotspot-windowsservercore-2019 => tag=windowsservercore-2019
    (dry-run) docker push jenkins4eval/jenkins:windowsservercore-2019
    Build finished successfully
    After:
    $ pwsh make.ps1 publish -DryRun
    = PREPARE: List of jenkins4eval/jenkins images and tags to be processed:
    name: jenkinsci-docker
    services:
      jdk11:
        build:
          context: /Users/veve/j-infra/jenkinsci-docker
          dockerfile: ./windows/windowsservercore/hotspot/Dockerfile
          args:
            COMMIT_SHA: 73a6176f2a18f9b69fc7a1c42fb338c43c9ef328
            JAVA_HOME: C:/openjdk-11
            JAVA_VERSION: 11.0.20.1_1
            JENKINS_SHA: C0FE49DBD53F7CC52D90810CECDEC6AB9B54665F4137977C2E7D7F642145E734
            JENKINS_VERSION: "2.431"
            TOOLS_WINDOWS_VERSION: "1809"
            WINDOWS_VERSION: ltsc2019
          tags:
          - jenkins4eval/jenkins:2.431-jdk11-hotspot-windowsservercore-ltsc2019
        image: jenkins4eval/jenkins:jdk11-hotspot-windowsservercore-ltsc2019
        networks:
          default: null
      jdk17:
        build:
          context: /Users/veve/j-infra/jenkinsci-docker
          dockerfile: ./windows/windowsservercore/hotspot/Dockerfile
          args:
            COMMIT_SHA: 73a6176f2a18f9b69fc7a1c42fb338c43c9ef328
            JAVA_HOME: C:/openjdk-17
            JAVA_VERSION: 17.0.9_9
            JENKINS_SHA: C0FE49DBD53F7CC52D90810CECDEC6AB9B54665F4137977C2E7D7F642145E734
            JENKINS_VERSION: "2.431"
            TOOLS_WINDOWS_VERSION: "1809"
            WINDOWS_VERSION: ltsc2019
          tags:
          - jenkins4eval/jenkins:2.431-jdk17-hotspot-windowsservercore-ltsc2019
          - jenkins4eval/jenkins:2.431-windowsservercore-ltsc2019
          - jenkins4eval/jenkins:windowsservercore-ltsc2019
        image: jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019
        networks:
          default: null
    networks:
      default:
        name: jenkinsci-docker_default
    = BUILD: Building all images...
    (dry-run) docker-compose --file=build-windows.yaml build --parallel --pull
    = BUILD: Finished building all images.
    Publishing jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019 => tag=jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019
    (dry-run) docker push jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019
    Publishing jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019 => tag=jenkins4eval/jenkins:2.431-jdk17-hotspot-windowsservercore-ltsc2019
    (dry-run) docker push jenkins4eval/jenkins:2.431-jdk17-hotspot-windowsservercore-ltsc2019
    Publishing jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019 => tag=jenkins4eval/jenkins:2.431-windowsservercore-ltsc2019
    (dry-run) docker push jenkins4eval/jenkins:2.431-windowsservercore-ltsc2019
    Publishing jenkins4eval/jenkins:jdk17-hotspot-windowsservercore-ltsc2019 => tag=jenkins4eval/jenkins:windowsservercore-ltsc2019
    (dry-run) docker push jenkins4eval/jenkins:windowsservercore-ltsc2019
    Publishing jenkins4eval/jenkins:jdk11-hotspot-windowsservercore-ltsc2019 => tag=jenkins4eval/jenkins:jdk11-hotspot-windowsservercore-ltsc2019
    (dry-run) docker push jenkins4eval/jenkins:jdk11-hotspot-windowsservercore-ltsc2019
    Publishing jenkins4eval/jenkins:jdk11-hotspot-windowsservercore-ltsc2019 => tag=jenkins4eval/jenkins:2.431-jdk11-hotspot-windowsservercore-ltsc2019
    (dry-run) docker push jenkins4eval/jenkins:2.431-jdk11-hotspot-windowsservercore-ltsc2019
    Build finished successfully
  • Ran make.ps1 test and make.ps1 publish from a Windows Server Core 2019 VM with $env:DOCKERHUB_ORGANISATION="hlemeur", based on the "prod-packer-images/providers/Microsoft.Compute/images/jenkins-agent-windows-2019" image used by ci.jenkins.io Azure VM agents

  • Full CI job with build and tests: https://ci.jenkins.io/job/Packaging/job/docker/job/PR-1770/155/

  • Test CI publication of Windows Server Core ltsc2019 & 2022 images to jenkins4eval/jenkins

    • https://ci.jenkins.io/job/Packaging/job/docker/job/PR-1770/154/

    • https://hub.docker.com/r/jenkins4eval/jenkins/tags

    • Jenkinsfile change for images publication test:
      --- old/Jenkinsfile
      +++ new/Jenkinsfile
      @@ -1,4 +1,13 @@
      #!/usr/bin/env groovy
                              // disable until we get the parallel changes merged in
                              // def branchName = "${env.BRANCH_NAME}"
                              // if (branchName ==~ 'master'){
      -                        //    stage('Publish Experimental') {
      -                        //        infra.withDockerCredentials {
      -                        //            withEnv(['DOCKERHUB_ORGANISATION=jenkins4eval','DOCKERHUB_REPO=jenkins']) {
      -                        //                powershell './make.ps1 publish'
      -                        //            }
      -                        //        }
      -                        //    }
      +                           stage('Publish Experimental') {
      +                               infra.withDockerCredentials {
      +                                   withEnv(['DOCKERHUB_ORGANISATION=jenkins4eval','DOCKERHUB_REPO=jenkins']) {
      +                                       powershell './make.ps1 publish'
      +                                   }
      +                               }
      +                           }

Submitter checklist

@lemeurherve lemeurherve changed the title wip feat(Windows): refactor build process Nov 3, 2023
@lemeurherve lemeurherve force-pushed the issue1489-windows-build-refactor branch 8 times, most recently from 740b16b to 9705dd3 Compare November 9, 2023 14:16
@lemeurherve lemeurherve marked this pull request as ready for review November 9, 2023 16:54
@lemeurherve lemeurherve requested a review from a team as a code owner November 9, 2023 16:54
@lemeurherve
Copy link
Member Author

@slide I'd appreciate a lot if you could take a look at this change and tell me what you think about it.

@lemeurherve lemeurherve force-pushed the issue1489-windows-build-refactor branch from c2488ae to 73a6176 Compare November 12, 2023 23:08
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

nice work

Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

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

Nice work 👏

Let's validate this PR with the upcoming 2.432 weekly release and the next LTS (in 2 days).

Then we'll be able to check the issues related to Windows image!

@dduportal dduportal merged commit 389ea8a into jenkinsci:master Nov 13, 2023
19 checks passed
@Jonny-vb
Copy link
Contributor

Thanks for doing something about this! Means a lot to the few of us out here using Windows 😀

@lemeurherve lemeurherve deleted the issue1489-windows-build-refactor branch November 13, 2023 19:22
ti-chi-bot bot referenced this pull request in PingCAP-QE/ee-ops Dec 17, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jenkins/jenkins](https://www.jenkins.io/)
([source](https://togithub.com/jenkinsci/docker)) | minor |
`2.414.3-lts` -> `2.426.2-lts` |

---

### Release Notes

<details>
<summary>jenkinsci/docker (jenkins/jenkins)</summary>

###
[`v2.426.2`](https://togithub.com/jenkinsci/docker/releases/tag/2.426.2)

[Compare
Source](https://togithub.com/jenkinsci/docker/compare/2.426.1...2.426.2)

<!-- Optional: add a release summary here -->

#### 📦 Jenkins Core updates

- Update to Jenkins 2.426.2
([changelog](https://jenkins.io/changelog-stable/#v2.426.2))

#### 🚀 New features and improvements

- Bump Alpine Linux Version to 3.19.0
([#&#8203;1795](https://togithub.com/jenkinsci/docker/issues/1795))
[@&#8203;github-actions](https://togithub.com/github-actions)

#### 👻 Maintenance

- chore: replace `curl.exe` by `Invoke-WebRequest`
([#&#8203;1796](https://togithub.com/jenkinsci/docker/issues/1796))
[@&#8203;lemeurherve](https://togithub.com/lemeurherve)

#### 📦 Dependency updates

- chore(deps): bump plugin manager to 2.12.14
([#&#8203;1794](https://togithub.com/jenkinsci/docker/issues/1794))
[@&#8203;jenkins-dependency-updater](https://togithub.com/jenkins-dependency-updater)
- chore(deps): bump updatecli/updatecli-action from 2.49.1 to 2.50.0
([#&#8203;1793](https://togithub.com/jenkinsci/docker/issues/1793))
[@&#8203;dependabot](https://togithub.com/dependabot)
- chore(deps): bump almalinux from 8.8 to 8.9 in
/11/almalinux/almalinux8/hotspot
([#&#8203;1791](https://togithub.com/jenkinsci/docker/issues/1791))
[@&#8203;dependabot](https://togithub.com/dependabot)
- Bump Debian Bookworm Linux Version to
[`2023112`](https://togithub.com/jenkinsci/docker/commit/20231120)
([#&#8203;1790](https://togithub.com/jenkinsci/docker/issues/1790))
[@&#8203;github-actions](https://togithub.com/github-actions)

#### 🐛 Bug fixes

- fix(Windows): add `lts-` prefix to LTS short tags not including
Jenkins version
([#&#8203;1784](https://togithub.com/jenkinsci/docker/issues/1784))
[@&#8203;lemeurherve](https://togithub.com/lemeurherve)

#### 📝 Documentation updates

- Add `JENKINS_PLUGIN_INFO` to the "Setting update centers" README
section
([#&#8203;1785](https://togithub.com/jenkinsci/docker/issues/1785))
[@&#8203;lemeurherve](https://togithub.com/lemeurherve)

**Full Changelog**:
jenkinsci/docker@2.426.1...2.426.2

###
[`v2.426.1`](https://togithub.com/jenkinsci/docker/releases/tag/2.426.1)

[Compare
Source](https://togithub.com/jenkinsci/docker/compare/2.414.3...2.426.1)

#### 📦 Jenkins Core updates

- Update to Jenkins 2.426.1
([changelog](https://www.jenkins.io/changelog-stable/#v2.426.1) and
[upgrade
guide](https://www.jenkins.io/doc/upgrade-guide/2.426/#upgrading-to-jenkins-lts-2-426-1)
)

#### 💥 Breaking changes

- Remove CentOS 7 container images by
[@&#8203;MarkEWaite](https://togithub.com/MarkEWaite) in
[https://github.com/jenkinsci/docker/pull/1777](https://togithub.com/jenkinsci/docker/pull/1777)
- breaking(Windows): set Java 17 as default by
[@&#8203;lemeurherve](https://togithub.com/lemeurherve) in
[https://github.com/jenkinsci/docker/pull/1773](https://togithub.com/jenkinsci/docker/pull/1773)

#### 🚀 New features and improvements

- feat(Windows): refactor build process by
[@&#8203;lemeurherve](https://togithub.com/lemeurherve) in
[https://github.com/jenkinsci/docker/pull/1770](https://togithub.com/jenkinsci/docker/pull/1770)
- Switch from a `windowsservercore-1809` Temurin base image to a
`windowsservercore-ltsc2019` Microsoft base image
([#&#8203;1775](https://togithub.com/jenkinsci/docker/issues/1775))
- A proper set of tags is now published, and they include "ltsc2019"
instead of only "2019"
([#&#8203;1489](https://togithub.com/jenkinsci/docker/issues/1489))
- A JDK11 image is published again alongside the JDK17 one
([#&#8203;1774](https://togithub.com/jenkinsci/docker/issues/1774))
- As Java 17 is the default JDK, short tags without "jdk" in them are
using Java 17
([#&#8203;1724](https://togithub.com/jenkinsci/docker/issues/1724))
- Switch to GA eclipse-temurin:jdk21 images by
[@&#8203;lemeurherve](https://togithub.com/lemeurherve) in
[https://github.com/jenkinsci/docker/pull/1738](https://togithub.com/jenkinsci/docker/pull/1738)

#### 🐛 Bug fixes

- fix: add additional tags for default Java images by
[@&#8203;lemeurherve](https://togithub.com/lemeurherve) in
[https://github.com/jenkinsci/docker/pull/1756](https://togithub.com/jenkinsci/docker/pull/1756)
- fixup: shortest jdk17 tags only for weekly releases by
[@&#8203;lemeurherve](https://togithub.com/lemeurherve) in
[https://github.com/jenkinsci/docker/pull/1757](https://togithub.com/jenkinsci/docker/pull/1757)

#### 📦 Dependency updates

- Bump Debian Bookworm Linux Version to
[`2023103`](https://togithub.com/jenkinsci/docker/commit/20231030) by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/jenkinsci/docker/pull/1765](https://togithub.com/jenkinsci/docker/pull/1765)
- Use JDK 21.0.1+12, not 21+35 by
[@&#8203;MarkEWaite](https://togithub.com/MarkEWaite) in
[https://github.com/jenkinsci/docker/pull/1779](https://togithub.com/jenkinsci/docker/pull/1779)
- Bump JDK21 preview version (EA) to 21.0.1+12 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/jenkinsci/docker/pull/1743](https://togithub.com/jenkinsci/docker/pull/1743)
- Use Java 17.0.9\_9 by
[@&#8203;MarkEWaite](https://togithub.com/MarkEWaite) in
[https://github.com/jenkinsci/docker/pull/1778](https://togithub.com/jenkinsci/docker/pull/1778)
- Bump JDK11 version to 11.0.21\_9 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[https://github.com/jenkinsci/docker/pull/1762](https://togithub.com/jenkinsci/docker/pull/1762)
& [@&#8203;lemeurherve](https://togithub.com/lemeurherve) in
[https://github.com/jenkinsci/docker/pull/1782](https://togithub.com/jenkinsci/docker/pull/1782)
- chore(deps): bump ubi9/ubi to 9.3-1361 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/jenkinsci/docker/pull/1776](https://togithub.com/jenkinsci/docker/pull/1776)
- chore(deps): bump ubi8/ubi to 8.8-1067.1698056881 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/jenkinsci/docker/pull/1760](https://togithub.com/jenkinsci/docker/pull/1760)

**Full Changelog**:
jenkinsci/docker@2.414.3...2.426.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/PingCAP-QE/ee-ops).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuODcuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants