- Builds a Docker image,
- Pushes it to Docker Hub,
- Updates the Kubernetes manifest in a Git repository,
- Raises a pull request so a GitOps operator (Argo CD) can reconcile the change.
highway-animation repository was imported into Gitea and the Jenkinsfile was modified for this flow.

- The pipeline previously failed because some stages referenced
deployment.yamlwhile the repository file is nameddeployment.yml. That made thesed/catcommands error out. - Always verify file names and paths in the workspace before running commands that assume a file exists.
Always validate filenames and paths in the pipeline workspace (for example
deployment.yml vs deployment.yaml) before using sed or cat to avoid stage failures.cgoa-demos/jenkins-demo and the manifest file is deployment.yml (note the single-letter extension):

- Builds and tags the Docker image using a deterministic
VERSION(combiningBUILD_IDandGIT_COMMIT), - Pushes the image to Docker Hub using stored credentials,
- Clones or pulls the
cgoa-demosrepo, updatesdeployment.ymlto the new image tag, commits, pushes and creates a PR.
- Create a new Jenkins job of type “Pipeline” that points to this Jenkinsfile in your source repository and run it.

main), then save:

- The pipeline will run stages for build, tag and push. Example shell output from the Build / Push stages:

- Ensure Jenkins has Docker Hub credentials configured in “Manage Jenkins” → “Credentials” and referenced by the pipeline (this example uses
docker-hub-credentials). - Also store the Gitea token as a Jenkins credential (here referenced as
gitea-token) so scripts can push and create PRs securely.
Store registry credentials and Git/Gitea tokens in Jenkins credentials (not inline in the pipeline). Avoid exposing tokens in console output and remote URLs without proper masking.

- After pushing the commit, the pipeline runs a helper script (for example
gitea-pr.sh) that calls the Gitea REST API to create a PR. Example response printed by such a script:
- Once the PR is merged to
main, Argo CD will observe the updateddeployment.ymlwith the new image tag — for example:
- When Argo CD detects the desired state in Git differs from cluster state it marks the application OutOfSync. You can then click Sync to roll out the new image.
- The Argo CD UI reports application health and sync status:

- If the release introduces a bug (for example UI regressions), Argo CD allows you to roll back to a previous revision in the cluster. Note: rollback reverts the live cluster state to a previous ReplicaSet but does not change the Git repository. After rollback you should:
- Fix the root cause in source control,
- Build and test a new image,
- Update manifests, push and merge the PR,
- Let Argo CD reconcile the corrected state.
DevSecOps considerations
- Add dependency scanning (e.g.,
npm audit, Snyk) before building images. - Scan images (e.g.,
trivy image) before pushing to the registry; fail builds on critical vulnerabilities. - Perform static analysis (SonarQube) and dynamic testing as appropriate.
- Builds and tags an image,
- Pushes it to Docker Hub,
- Updates Kubernetes manifests in Git,
- Opens a PR so a GitOps operator (Argo CD) can pick up and deploy the change.
- GitOps with ArgoCD course
- Jenkins course
- Argo CD documentation: https://argo-cd.readthedocs.io/
- Trivy: https://github.com/aquasecurity/trivy