Skip to content

Сборка докер-образа v1 и v2 на Jenkins#1565

Merged
EvilBeaver merged 5 commits intodevelopfrom
feature/docker-build
Nov 22, 2025
Merged

Сборка докер-образа v1 и v2 на Jenkins#1565
EvilBeaver merged 5 commits intodevelopfrom
feature/docker-build

Conversation

@nixel2007
Copy link
Collaborator

@nixel2007 nixel2007 commented Aug 6, 2025

Closes #1563

С закомментированным пушем на тестовой ветке: https://build.oscript.io/job/docker-publish/job/feature%252Fdocker-build/19/

Summary by CodeRabbit

  • Chores

    • Added environment variables in the base image so installed tools are available on the PATH.
    • Upgraded the base runtime image to a newer .NET 8.0 runtime for improved compatibility.
  • New Features

    • CI pipeline now builds and publishes multiple Docker image variants in parallel with clearer branch/tag conditions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

Adds PATH-exporting environment variables to Dockerfile_v1, upgrades Dockerfile_v2 base image to .NET 8.0-jammy, and adds parallel "Publishing docker-images" stages plus a new publishDockerImage(flavour, codename) function in the Jenkins pipeline to build and push flavour-specific images.

Changes

Cohort / File(s) Change Summary
Dockerfile v1: Env & PATH
install/builders/base-image/Dockerfile_v1
Sets OSCRIPTBIN=/root/.local/share/ovm/current/bin and appends it to PATH after installing the engine via ovm.
Dockerfile v2: Base image bump
install/builders/base-image/Dockerfile_v2
Updates base image from mcr.microsoft.com/dotnet/aspnet:6.0-jammy to mcr.microsoft.com/dotnet/aspnet:8.0-jammy.
Jenkins pipeline: Docker publish
Jenkinsfile
Adds parallel "Publishing docker-images" group with "Build v1" and "Build v2" stages (branch/tag guards) and introduces def publishDockerImage(flavour, codename) to build and push evilbeaver/onescript:${codename} using flavour-specific Dockerfiles; minor formatting tweaks in when blocks.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant J as Jenkins
    participant Reg as Registry

    Dev->>J: Push commit or tag
    J->>J: Evaluate when conditions (branch/tag)
    alt matches v1
        J->>J: Run "Build v1" stage
        J->>J: publishDockerImage("v1", codename)
    end
    alt matches v2
        J->>J: Run "Build v2" stage
        J->>J: publishDockerImage("v2", codename)
    end
    note right of J `#DDEEEF`: publishDockerImage builds using flavour-specific Dockerfile
    J->>Reg: Tag & push evilbeaver/onescript:${codename}
    Reg-->>J: Acknowledge push
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus:
    • Jenkinsfile: correctness of when conditions, codename derivation, publishDockerImage implementation and credentials/push steps.
    • install/builders/base-image/Dockerfile_v1: verify PATH placement and runtime visibility of ovm-installed binaries.
    • install/builders/base-image/Dockerfile_v2: confirm compatibility of .NET 8.0 base with existing runtime expectations.

Poem

I hopped through layers, code and vine,
Placed PATH breadcrumbs where binaries shine,
Bumped the base to a newer dawn,
Launched two builds and watched them run,
A rabbit readies images — now they're gone 🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes the main change: enabling Docker image building for v1 and v2 versions via Jenkins automation, which aligns with the primary purpose of the PR.
Linked Issues check ✅ Passed The PR implements Docker image building and publishing infrastructure for v1 and v2 via Jenkins, partially addressing the requirement to publish images for dev/latest/numbered versions.
Out of Scope Changes check ✅ Passed All changes are scoped to Docker image building: Dockerfile updates for environment configuration and base image version, and Jenkins pipeline additions for publishing automation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/docker-build

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e8ad5d and 55cb65e.

📒 Files selected for processing (1)
  • Jenkinsfile (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Jenkinsfile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: SonarQube
  • GitHub Check: SonarQube

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nixel2007 nixel2007 requested a review from EvilBeaver August 6, 2025 06:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
docker-build.Jenkinsfile (1)

47-50: Consistent Docker operations for v2 stage.

The v2 build stage uses the same pattern as v1, which provides consistency. However, it inherits the same issues with authentication and error handling.

🧹 Nitpick comments (1)
docker-build.Jenkinsfile (1)

6-8: Consider making Docker username configurable.

The hardcoded username should be made configurable through Jenkins credentials or environment variables for better flexibility and security.

 environment {
-    DOCKER_USERNAME = "evilbeaver"
+    DOCKER_USERNAME = credentials('docker-username')
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd9b7e4 and e17fe9a.

📒 Files selected for processing (3)
  • docker-build.Jenkinsfile (1 hunks)
  • install/builders/base-image/Dockerfile_v1 (1 hunks)
  • install/builders/base-image/Dockerfile_v2 (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: EvilBeaver
PR: EvilBeaver/OneScript#0
File: :0-0
Timestamp: 2024-08-05T18:27:08.563Z
Learning: For each new pull request in the EvilBeaver/OneScript repository, include a poem in Russian.
📚 Learning: use 'dotnet oscript.dll tests/testrunner.os -runall tests' to run acceptance tests...
Learnt from: CR
PR: EvilBeaver/OneScript#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T07:12:50.869Z
Learning: Use 'dotnet oscript.dll tests/testrunner.os -runAll tests' to run acceptance tests

Applied to files:

  • install/builders/base-image/Dockerfile_v1
🔇 Additional comments (8)
install/builders/base-image/Dockerfile_v2 (1)

14-14: Confirmed .NET 8.0 support in build configuration

  • Build.csproj defines <ActiveFramework>net8.0</ActiveFramework>.
  • TestApp.csproj targets net8.0-windows.
  • No remaining references to .NET 6.0 in project files.

The Docker base image update (aspnet:6.0-jammyaspnet:8.0-jammy) now matches the solution’s .NET 8.0 targets. No further action needed.

install/builders/base-image/Dockerfile_v1 (2)

11-11: Line continuation added correctly.

The backslash continuation is properly added to maintain the RUN command structure.


13-14: Validate ovm symlink path consistency

The ENV OSCRIPTBIN and PATH settings in Dockerfile_v1 correctly aim to expose the ovm binaries, but they rely on a hardcoded /root/.local/share/ovm/current/bin. In contrast, Dockerfile_v2 pulls directly from the versioned directory (/root/.local/share/ovm/${VERSION}/) into /var/oscript.

Please verify that running

mono ovm.exe use --install $VERSION

actually creates a current symlink under ~/.local/share/ovm pointing at the installed version’s folder. If no such symlink exists, you should either:

  • Update Dockerfile_v1 to consume the version directory directly (e.g. add ARG VERSION and use /root/.local/share/ovm/${VERSION}/bin), or
  • Adopt the v2 approach: COPY --from=0 /root/.local/share/ovm/${VERSION}/ /var/oscript/ and ENV PATH="$PATH:/var/oscript/bin" for consistency across builds.

Points to verify:

  • Check the ovm documentation or a local install to confirm use --install creates .../ovm/current/bin.
  • Ensure both Dockerfiles follow a consistent installation pattern.
docker-build.Jenkinsfile (5)

12-19: Build v1 condition logic is correct.

The conditional logic properly handles both branch-based (release/latest) and tag-based (v1.*) triggers for the v1 build stage.


22-23: Tag naming strategy aligns with objectives.

The dynamic tag assignment (using TAG_NAME or defaulting to 'latest') properly supports the requirement for publishing dev, latest, and numbered release versions.


34-41: Build v2 condition logic is correct.

The conditional logic properly handles both branch-based (develop) and tag-based (v2.*) triggers for the v2 build stage.


44-44: Appropriate default tag for v2 builds.

Using 'dev' as the default tag for v2 builds from the develop branch is appropriate and aligns with the development workflow.


1-55: Pipeline successfully implements automatic Docker publishing objectives.

This Jenkins pipeline effectively addresses the PR objectives by automating Docker image publishing for different release channels (dev, latest, numbered versions). The two-stage approach allows for separate v1 and v2 image lifecycles.

Russian poem as requested:

Докер-образы теперь летят,
Дженкинс строит их подряд.
v1, v2 — версий парад,
Автоматизации клад!

OneScript в контейнерах живёт,
EvilBeaver код даёт.
Сборка, тэги — всё идёт,
Разработка процветёт!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e17fe9a and d05c5fc.

📒 Files selected for processing (1)
  • Jenkinsfile (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: EvilBeaver
PR: EvilBeaver/OneScript#0
File: :0-0
Timestamp: 2024-08-05T18:27:08.563Z
Learning: For each new pull request in the EvilBeaver/OneScript repository, include a poem in Russian.
Learnt from: nixel2007
PR: EvilBeaver/OneScript#1565
File: docker-build.Jenkinsfile:25-28
Timestamp: 2025-08-06T07:01:44.782Z
Learning: In the EvilBeaver/OneScript repository, Docker authentication for Jenkins pipelines is configured at the Jenkins settings level, so explicit Docker registry authentication (like docker.withRegistry) is not needed in Jenkinsfiles.
📚 Learning: in the evilbeaver/onescript repository, docker authentication for jenkins pipelines is configured at...
Learnt from: nixel2007
PR: EvilBeaver/OneScript#1565
File: docker-build.Jenkinsfile:25-28
Timestamp: 2025-08-06T07:01:44.782Z
Learning: In the EvilBeaver/OneScript repository, Docker authentication for Jenkins pipelines is configured at the Jenkins settings level, so explicit Docker registry authentication (like docker.withRegistry) is not needed in Jenkinsfiles.

Applied to files:

  • Jenkinsfile

@nixel2007 nixel2007 force-pushed the feature/docker-build branch from d05c5fc to 74f7670 Compare August 7, 2025 05:43
@nixel2007 nixel2007 force-pushed the feature/docker-build branch from 74f7670 to be55753 Compare August 7, 2025 05:57
@nixel2007 nixel2007 self-assigned this Nov 21, 2025
Copilot AI review requested due to automatic review settings November 21, 2025 13:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds automated Docker image building and publishing to the Jenkins CI/CD pipeline for both v1 and v2 versions of OneScript. The changes support building different image flavors based on branches and tags, with v1 targeting stable releases and v2 targeting development builds.

Key changes:

  • Added a new Jenkins pipeline stage to build and publish Docker images in parallel for v1 and v2 flavors
  • Updated base Docker images: v1 now includes environment variables for executable paths, v2 upgraded to .NET 8.0
  • Reformatted when conditions in existing pipeline stages for consistency

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Jenkinsfile Added new parallel stage for building Docker images with branch/tag-based conditions and a helper function to build and push images
install/builders/base-image/Dockerfile_v1 Added PATH environment variables to make oscript executables available in the container
install/builders/base-image/Dockerfile_v2 Upgraded base image from .NET 6.0 to 8.0 for improved compatibility

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6fb819 and 5e8ad5d.

📒 Files selected for processing (1)
  • Jenkinsfile (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: EvilBeaver
Repo: EvilBeaver/OneScript PR: 0
File: :0-0
Timestamp: 2024-08-05T18:27:08.563Z
Learning: For each new pull request in the EvilBeaver/OneScript repository, include a poem in Russian.
Learnt from: nixel2007
Repo: EvilBeaver/OneScript PR: 1565
File: docker-build.Jenkinsfile:25-28
Timestamp: 2025-08-06T07:01:44.814Z
Learning: In the EvilBeaver/OneScript repository, Docker authentication for Jenkins pipelines is configured at the Jenkins settings level, so explicit Docker registry authentication (like docker.withRegistry) is not needed in Jenkinsfiles.
📚 Learning: 2025-08-06T07:01:44.814Z
Learnt from: nixel2007
Repo: EvilBeaver/OneScript PR: 1565
File: docker-build.Jenkinsfile:25-28
Timestamp: 2025-08-06T07:01:44.814Z
Learning: In the EvilBeaver/OneScript repository, Docker authentication for Jenkins pipelines is configured at the Jenkins settings level, so explicit Docker registry authentication (like docker.withRegistry) is not needed in Jenkinsfiles.

Applied to files:

  • Jenkinsfile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: SonarQube
  • GitHub Check: SonarQube
🔇 Additional comments (3)
Jenkinsfile (3)

267-274: Verify branch filtering logic aligns with release strategy.

The condition for v1 uses branch 'release/latest', while v2 uses branch 'develop'. Per the PR objectives, ensure this reflects the intended publishing channels (v1 → "latest", v2 → "dev"). Verify with the team that the branch names are correct and that no other release branches (e.g., release/preview) should trigger Docker builds.


275-280: Approve v1 build stage structure.

The stage('Build v1') block is well-formed: correct agent label, proper when conditions, and explicit script wrapping the docker call.


202-206: Approve formatting changes to when blocks.

The refactoring of the when blocks in "Publishing night-build" (lines 202–206) and "Publishing preview" (lines 220–224) preserves functional behavior while improving consistency.

Also applies to: 220-224

Comment on lines +344 to +351
def publishDockerImage(flavour, codename) {
def imageName = "evilbeaver/onescript:${codename}"

docker.build(
imageName,
"--load -f install/builders/base-image/Dockerfile_${flavour} ."
).push()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Sanitize Docker tag to prevent invalid characters in image name.

The codename variable derived from branch names or tags may contain characters invalid for Docker tags (e.g., slashes in branch names). While the current conditions (release/latest, develop, tags starting with v1., v2.) appear safe, explicitly sanitizing the tag prevents future regressions if conditions change.

 def publishDockerImage(flavour, codename) {
-    def imageName = "evilbeaver/onescript:${codename}"
+    def sanitizedTag = codename.replaceAll('[^A-Za-z0-9._-]', '_')
+    def imageName = "evilbeaver/onescript:${sanitizedTag}"
 
     docker.build(
         imageName,
         "--load -f install/builders/base-image/Dockerfile_${flavour} ."
     ).push()
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def publishDockerImage(flavour, codename) {
def imageName = "evilbeaver/onescript:${codename}"
docker.build(
imageName,
"--load -f install/builders/base-image/Dockerfile_${flavour} ."
).push()
}
def publishDockerImage(flavour, codename) {
def sanitizedTag = codename.replaceAll('[^A-Za-z0-9._-]', '_')
def imageName = "evilbeaver/onescript:${sanitizedTag}"
docker.build(
imageName,
"--load -f install/builders/base-image/Dockerfile_${flavour} ."
).push()
}
🤖 Prompt for AI Agents
In Jenkinsfile around lines 344 to 351, the codename is used directly as a
Docker tag but may contain characters invalid for Docker tags; sanitize it by
creating a safeTag: convert to lowercase, replace any character not in
[a-z0-9A-Z_.-] with a hyphen (or remove), collapse consecutive hyphens, trim
leading/trailing dots or hyphens, and truncate to Docker's 128-character limit;
then use this safeTag when building/pushing the image instead of the raw
codename.

@sonar-openbsl-ru-qa-bot
Copy link

@EvilBeaver EvilBeaver merged commit fa77edf into develop Nov 22, 2025
3 of 4 checks passed
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.

Публиковать образы docker при сборках

3 participants