Skip to content

Conversation

buccarel
Copy link
Contributor

@buccarel buccarel commented Nov 2, 2023

Fixes the following issue:
#88

Definition of done:
[x] Implementation of the runner
[x] Unit tests
[x] Local tests

Jenkins output of att init

image

Generated chainloop_attestation.tmp.json

image


import "os"

type JenkinsJob struct{}
Copy link
Member

Choose a reason for hiding this comment

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

This is not related to your change, since the other runners have the same issue, but it's something that we could tackle in another patch.

It seems that the "factory functions" are not being used outside of tests, when they could also be used in runner.go in the switch clause.

@migmartri
Copy link
Member

To run this locally, since this is just a client-side update you have two options:

a) run full development environment including CAS, controlplane locally or
b) just run your CLI pointing to the already existing SASS chainloop instance

For the latter, and to perform an attestation, even locally, you need to configure a workflow + robot-account and this is how you do it.

  • login to the controlplane go run main.go auth login
  • Create an empty contract (github.yaml) that sets the new runner requirement
schemaVersion: v1

runner:
  type: "JENKINS_JOB"
  • create a workflow pointing to that empty contract, that should return a robot-account. This is an API token that's used during attestation.
go run main.go wf create --name test --project jktest --contract jenkins.yaml

Export the robot-account as an env variable

export CHAINLOOP_ROBOT_ACCOUNT=REDACTED.REDACTED.tBAf4SzsCWjFzuaS9R6a0PBNSo2_wdPjZKH1x_ogObc

and then run an attestation init, you should get the expected error

$ go run main.go att init                                                           
ERR The contract expects the attestation to be crafted in a runner of type "jenkins-job" but couldn't be detected. Use --dry-run flag if development

after this you know how to proceed, impersonating the env vars or even running the modified version of this CLI (compiled with make -C app/cli build in a Jenkins runner.

I hope it helps

@migmartri
Copy link
Member

#412 has been merged, please rebase main now, thanks!

@buccarel buccarel marked this pull request as ready for review November 3, 2023 16:53
@buccarel buccarel requested a review from migmartri November 3, 2023 18:11
Copy link
Member

@migmartri migmartri left a comment

Choose a reason for hiding this comment

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

LGTM!

Next we'll need to update the docs https://docs.chainloop.dev/reference/operator/contract#runner-context but we can wait until they are moved to the main repo. @danlishka is working on that

Thanks!

Signed-off-by: Mattia Buccarella <m.buccarella@gmail.com>
Signed-off-by: Mattia Buccarella <m.buccarella@gmail.com>
Signed-off-by: Mattia Buccarella <m.buccarella@gmail.com>
Signed-off-by: Mattia Buccarella <m.buccarella@gmail.com>
@migmartri migmartri merged commit 0ff6fe6 into chainloop-dev:main Nov 6, 2023
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.

2 participants