Skip to content

Commit

Permalink
Merge pull request #487 from Vandebron/feature/remove-unessential-dep…
Browse files Browse the repository at this point in the history
…endencies

feature/remove unessential dependencies
  • Loading branch information
SamTheisens authored Oct 13, 2024
2 parents 8e466f2 + 2877ac3 commit 1b0737d
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 765 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
spark-operator-chart-version: 1.1.25

- name: Check mpyl health
run: mpyl health --ci
run: mpyl health

- name: Lint projects
run: mpyl projects lint
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ slack-sdk = "==3.21.3"
atlassian-python-api = "==3.39.0"
click = "==8.1.7"
rich = "==13.8.0"
jenkinsapi = "==0.3.13"
pyaml-env = "==1.2.1"
python-dotenv = "==1.0.0"
questionary = "==2.0.1"
Expand Down
201 changes: 93 additions & 108 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions mpyl_config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ docker:
compose:
periodSeconds: 2
failureThreshold: 20
jenkins:
url: 'https://acme.infra.nl/'
pipelines:
some-pipeline: 'Acme Pipeline - Main'
mpyl-test: 'MPyL Pipeline - Test'
defaultPipeline: 'mpyl-test'
sbt:
command: 'sbt'
clientCommand: 'sbtn'
Expand Down
9 changes: 9 additions & 0 deletions releases/notes/1.7.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#### Demonstrate MPyL plugin mechanism.
MPyL allows steps to be implemented outside and registered via a [plugin mechanism](https://vandebron.github.io/mpyl/mpyl/steps.html)

Creating steps outside the MPyL library gives a much quicker roundtrip,
because you can build and test steps locally in the repo in which you're using MPyL.

The mechanism is demonstrated in [plugin-run.py](../../plugin-run.py) which imports two
[Gradle](https://gradle.org/) build steps defined in [plugins/gradle.py](../../plugins/gradle.py).
3 changes: 1 addition & 2 deletions src/mpyl/artifacts/build_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
from git.exc import GitCommandError
from github import Github

from ..cli.commands.build.jenkins import get_token
from ..constants import RUN_ARTIFACTS_FOLDER
from ..project import Project, Target, load_project
from ..steps.deploy.k8s.deploy_config import DeployConfig, get_namespace
from ..steps.models import RunProperties
from ..utilities.github import GithubConfig
from ..utilities.github import GithubConfig, get_token
from ..utilities.repo import Repository, RepoConfig


Expand Down
128 changes: 1 addition & 127 deletions src/mpyl/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
)
from . import create_console_logger
from .commands.build.artifacts import prepare_artifacts_repo, branch_name
from .commands.build.jenkins import JenkinsRunParameters, run_jenkins, get_token
from ..artifacts.build_artifacts import (
ManifestPathTransformer,
BuildCacheTransformer,
Expand All @@ -46,7 +45,7 @@
from ..steps.deploy.k8s.deploy_config import DeployConfig
from ..steps.models import RunProperties
from ..steps.run_properties import construct_run_properties
from ..utilities.github import GithubConfig
from ..utilities.github import GithubConfig, get_token
from ..utilities.pyaml_env import parse_config
from ..utilities.repo import Repository, RepoConfig

Expand Down Expand Up @@ -322,131 +321,6 @@ def ask_for_tag_input(ctx, _param, value) -> Optional[str]:
return value


@build.command(help="Run a multi branch pipeline build on Jenkins")
@click.option(
"--user",
"-u",
help="Authentication API user. Can be set via env var JENKINS_USER",
envvar="JENKINS_USER",
type=click.STRING,
required=True,
)
@click.option(
"--password",
"-p",
help="Authentication API password. Can be set via env var JENKINS_PASSWORD",
envvar="JENKINS_PASSWORD",
type=click.STRING,
required=True,
)
@click.option(
"--pipeline",
"-pl",
help="The pipeline to run. Must be one of the pipelines listed in `jenkins.pipelines`. "
"Default value is `jenkins.defaultPipeline`",
type=Pipeline(),
required=False,
)
@click.option(
"--version",
"-v",
help="A specific version on https://pypi.org/project/mpyl/ to use for the build.",
type=click.STRING,
required=False,
)
@click.option(
"--test",
"-t",
help="The version supplied by `--version` should be considered from the Test PyPi mirror at"
" https://test.pypi.org/project/mpyl/.",
is_flag=True,
default=False,
required=False,
)
@click.option(
"--arguments",
"-a",
multiple=True,
help="A series of arguments to pass to the pipeline. Note that will run within the pipenv in jenkins. "
"To execute `mpyl build status`, pass `-a run -a mpyl -a build -a status`",
)
@click.option(
"--background",
"-bg",
help="Starts Jenkins build in a 'fire and forget' fashion. "
"Can be set via env var MPYL_JENKINS_BACKGROUND",
envvar="MPYL_JENKINS_BACKGROUND",
is_flag=True,
default=False,
)
@click.option(
"--silent",
"-s",
help="Indicates whether to show Jenkins' logging or not. "
"Can be set via env var MPYL_JENKINS_SILENT",
envvar="MPYL_JENKINS_SILENT",
is_flag=True,
default=False,
)
@click.option(
"--tag",
is_flag=False,
flag_value="prompt",
default="not_set",
callback=ask_for_tag_input,
)
@click.pass_context
def jenkins( # pylint: disable=too-many-arguments, too-many-locals
ctx,
user,
password,
pipeline,
version,
test,
arguments,
background,
silent,
tag,
):
try:
asyncio.run(warn_if_update(ctx.obj.console))
if "jenkins" not in ctx.obj.config:
ctx.obj.console.print(
"No Jenkins configuration found in config file. "
"Please add a `jenkins` section to your MPyL config file."
)
sys.exit(0)
jenkins_config = ctx.obj.config["jenkins"]

selected_pipeline = pipeline if pipeline else jenkins_config["defaultPipeline"]
pipeline_parameters = (
{"TEST": "true" if test else "false", "VERSION": version} if version else {}
)
if arguments:
pipeline_parameters["BUILD_PARAMS"] = " ".join(arguments)

targets = (
select_targets()
if tag
else [Target.PULL_REQUEST.name] # pylint: disable=no-member
)
for target in targets:
run_argument = JenkinsRunParameters(
jenkins_user=user,
jenkins_password=password,
config=ctx.obj.config,
pipeline=selected_pipeline,
pipeline_parameters=pipeline_parameters,
verbose=not silent or ctx.obj.verbose,
follow=not background,
tag=tag,
tag_target=getattr(Target, target) if tag else None,
)
run_jenkins(run_argument)
except asyncio.exceptions.TimeoutError:
pass


@build.command(help=f"Clean all MPyL metadata in `{RUN_ARTIFACTS_FOLDER}` folders")
@click.option(
"--filter",
Expand Down
137 changes: 0 additions & 137 deletions src/mpyl/cli/commands/build/jenkins.py

This file was deleted.

Loading

0 comments on commit 1b0737d

Please sign in to comment.