Matrix build from "file:variable" (OD-2649)
pim opened 1 month ago

In onedev CI I'm attempting to run a commandstep for multiple versions of docker images that I built in a different project. To do this matrix step I define my docker image like so:

Screenshot From 2025-12-29 12-08-52.png

This won't work because as written here, you cannot use the "file" statement for a commandstep. It does work for "run docker container".

I have code that I want to run inside my container that I'd rather not include in the build process of my images. Passing the entire script as an argument or mounting my script (that is not even located in the current workspace) to the container seems like a lot of work.

The fix of running docker inside docker (as suggested in: OD-2616) would not work for me since I want to run the step as a matrix.

Is there a method I overlooked?

  • Robin Shen commented 4 weeks ago

    This will be addressed via issue OD-2652

  • Robin Shen changed state to 'Closed' 4 weeks ago
    Previous Value Current Value
    Open
    Closed
  • pim commented 3 weeks ago

    Thank you for implementing this @robin !

    I tried using values from file for matrix building but I keep getting the same error: docker: invalid reference format

    The image is specified like so: my-docker-image-name:@file:VERSIONS@ And my "VERSIONS" file looks like this:

    5.6.6
    7.2.0
    

    How should I format my values? Should I be using something like json/yml/toml or is comma-seperation or just one value per line?

  • Robin Shen commented 3 weeks ago

    OneDev matrix build can only be fired via job parameter. Below build spec demonstrates how to trigger the "test" job for each image in images.txt published by the "build" job:

    version: 43
    jobs:
    - name: build
      steps:
      - type: CommandStep
        name: build
        runInContainer: true
        image: ubuntu
        interpreter:
          type: DefaultInterpreter
          commands: |
            echo "ubuntu\nalpine" > images.txt
        useTTY: true
        condition: SUCCESSFUL
        optional: false
      - type: PublishArtifactStep
        name: publish
        artifacts: images.txt
        condition: SUCCESSFUL
        optional: false
      retryCondition: never
      maxRetries: 3
      retryDelay: 30
      timeout: 14400
      postBuildActions:
      - type: RunJobAction
        condition: successful
        jobName: test
        paramMatrix:
        - name: image
          secret: false
          valuesProvider:
            type: ScriptingValues
            scriptName: get-images
    - name: test
      steps:
      - type: CommandStep
        name: test
        runInContainer: true
        image: '@param:image@'
        interpreter:
          type: DefaultInterpreter
          commands: |
            cat /etc/os-release
        useTTY: true
        condition: SUCCESSFUL
        optional: false
      paramSpecs:
      - type: TextParam
        name: image
        allowEmpty: false
        multiline: false
      retryCondition: never
      maxRetries: 3
      retryDelay: 30
      timeout: 14400
    stepTemplates:
    - name: test
      paramSpecs:
      - type: TextParam
        name: image
        allowEmpty: false
        multiline: false
    

    This spec uses a groovy script "get-images" which should be defined in Administration / Groovy Scripts with below content:

    return new File(build.artifactsDir, "images.txt").readLines()
    
  • pim commented 3 weeks ago

    Thank you! This is works great.

issue 1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2649
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover