Prepare Duo Workfklow in CI to push code by creating branch
What does this MR do and why?
Currently, Duo Workflow in Remote Execution will run in a CI Pipeline, and then add a diff file called workflow.diff in the artifacts. This MR passes the branch name created for the job from Ci::Workloads::RunWorkloadService into the Workload object, and then switches to that branch inside the job. This is required because we remove the normal CI variables in this job, here.
Service will then commit and push to the branch, here.
This also passes the workflow_definition to the job, which will be required by the executor inside the job.
This addresses this issue.
How to set up and validate locally
Set up Duo Workflow locally with the instructions here, here, and here.
Run a new workflow through the API with:
curl --location 'http://gdk.test:3000/api/v4/ai/duo_workflows/workflows' \
--header 'Content-Type: application/json' \
--header 'PRIVATE-TOKEN: PAT' \
--data '{
"project_id": "1000000",
"goal": "JenkinsFile",
"workflow_definition": "convert_to_gitlab_ci",
"start_workflow": true,
"agent_privileges": [1,2,3,5]
}'
If you want to validate, you can use two methods: You add %(sleep 2000) to the commands in Ai::DuoWorkflows::Workload, and then get into the docker container with:
# To get container ID
docker ps
# To get into the running container
docker exec -it <Container ID> bash
# Validate branch:
git branch
# Validate environment variable:
echo $DUO_WORKFLOW_DEFINITION
You can also see the output of the job to see the switch to the branch was successful:
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #516132 (closed)
