Build before docker push

my project need java17, and the host is java11. What can I do to build with java17 and then push to space registry

host("Build artifacts and a Docker image") {
shellScript {
content = """
./gradlew bootJar
""".trimIndent()
}
// push to space registry
dockerBuildPush {
...
}
}
0
1 comment

Hi! The easiest way right now is to use a specific container that you need for a build and use our fileshare (https://www.jetbrains.com/help/space/sharing-execution-context.html#accessing-file-share-directly ) feature to provide files to the `dockerBuildPush` action.

container(image = "amazoncorretto:17.0.6", displayName = "Build artifacts") {
    shellScript {
        content = """
            ./gradlew bootJar

          cp build/my-app.jar "${'$'}JB_SPACE_FILE_SHARE_PATH/my-app.jar"
        """ 
    }
}

host("Push Docker image") {
    shellScript {
        content = """
            mkdir -p build
          cp "${'$'}JB_SPACE_FILE_SHARE_PATH/my-app.jar" build/my-app.jar
        """.trimIndent()
    }
    // push to space registry
    dockerBuildPush {
        ...
    }
}

This approach will be much simplified when we'll have `container` actions inside host - https://youtrack.jetbrains.com/issue/SPACE-18069/Introduce-container-host-actions.

0

Please sign in to leave a comment.