iver-wharf / iver-wharf.github.io

Documentation of Wharf
https://iver-wharf.github.io
MIT License
2 stars 0 forks source link

Automatic artifact uploads #52

Closed applejag closed 2 years ago

applejag commented 3 years ago

Regards the "container" step

This is no longer relevant as we're transitioning away from Jenkins. However, the feature itself is still heavily requested.

Once the cmd repo has been transferred (see #32) we can add a new issue there with the equivalent feature request, as well as closing this issue.

Todo

Example step config

container:
  image: mcr.microsoft.com/dotnet/core/sdk:3.1
  cmds:
  - dotnet test /repo/src/Iver.Spark.sln --results-directory /test-results
  artifacts:
  - /test-results

To consider: curl and wget will not exist on every image that's used. It's really bad habit to assume the image using is either Linux, have certain tools preinstalled, or even has permission to do some stuff.

Good option is to mount a second container, for example how they do it in their example found in the README.md: https://github.com/jenkinsci/kubernetes-plugin#container-group-support

Trimmed down example of just that:

podTemplate(containers: [
    containerTemplate(name: 'main', image: '$CONTAINER_IMAGE', ttyEnabled: true, command: 'cat'),
    containerTemplate(name: 'artifacts', image: 'ubuntu:20.04', ttyEnabled: true, command: 'cat')
  ]) {

    node(POD_LABEL) {
        stage('Run container commands') {
            git 'https://github.com/jenkinsci/kubernetes-plugin.git'
            container('maven') {
                sh CONTAINER_CMDS
            }
        }

        if (CONTAINER_ARTIFACTS) {
            stage('Upload artifacts') {
                container('golang') {
                    sh"""
                    for file in $CONTAINER_ARTIFACTS/*; do
                        curl $WHARF_API/something/artifacts
                    done
                    """
                }
            }
        }
    }
}
applejag commented 2 years ago

This is outdated and will be resolved in https://github.com/iver-wharf/rfcs/pull/25