Initial copy and move of initial tasks.

This commit is contained in:
jimmy committed 2023-04-01 20:24:18 -04:00
commit 7d24fd9c5e
15 files changed
+342

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: j7s-ansible-build
namespace: j7s-ci
spec:
workspaces:
- name: source
- name: ssh-directory
params:
- name: deploy
- name: ansible-file-path
steps:
- image: harbor.internal.jpace121.net/k8s/ansible-podman:latest
securityContext:
privileged: true
script: |
#!/usr/bin/env bash
set -ex
cp -r $(workspaces.ssh-directory.path) ~/.ssh
chmod 700 ~/.ssh
chmod -R 400 ~/.ssh/*
cd $(workspaces.source.path)
ansible-playbook -vvvv --skip-tags deploy -i $(params.ansible-file-path)/inventory.yaml $(params.ansible-file-path)/build.yaml
if [[ $(params.deploy) == "true" ]]; then
ansible-playbook -vvvv --tags deploy -i $(params.ansible-file-path)/inventory.yaml $(params.ansible-file-path)/build.yaml
fi
+71
View File
@@ -0,0 +1,71 @@
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: j7s-buildah
namespace: j7s-ci
spec:
description: Build and push a container image.
params:
- name: registry
description: Registry to push to.
- name: name
description: Name of the image.
- name: version
description: Version for the image.
- name: containerfile
description: Path of the Containerfile relative to source.
- name: registry-login-secret-name
description: Name of the secret containing the credentials to push to the registry.
workspaces:
- name: source
- name: cosign-credentials
steps:
- name: build
image: harbor.internal.jpace121.net/buildah:latest
workingDir: $(workspaces.source.path)
script: |
set -x
# Login
buildah login --tls-verify=false --username=$USERNAME --password=$PASSWORD $(params.registry)
mkdir ~/.sigstore
cp $(workspaces.cosign-credentials.path)/* ~/.sigstore
cat <<EOF > ~/.sigstore/param-file.yaml
privateKeyFile: "$HOME/.sigstore/cosign.key"
privateKeyPassphraseFile: "$HOME/.sigstore/cosign.password"
EOF
mkdir -p /etc/containers/registries.d/
cat <<EOF > /etc/containers/registries.d/james-registry.yaml
docker:
$(params.registry):
use-sigstore-attachments: true
EOF
# Build
buildah --storage-driver=overlay bud --tls-verify=false --no-cache \
-f $(params.containerfile) -t $(params.name):$(params.version) .
# Push
skopeo copy --dest-tls-verify=false --sign-by-sigstore=$HOME/.sigstore/param-file.yaml \
containers-storage:localhost/$(params.name):$(params.version) \
docker://$(params.registry)/$(params.name):$(params.version)
skopeo copy --dest-tls-verify=false --sign-by-sigstore=$HOME/.sigstore/param-file.yaml \
containers-storage:localhost/$(params.name):$(params.version) \
docker://$(params.registry)/$(params.name):latest
env:
- name: USERNAME
valueFrom:
secretKeyRef:
name: $(params.registry-login-secret-name)
key: username
- name: PASSWORD
valueFrom:
secretKeyRef:
name: $(params.registry-login-secret-name)
key: password
volumeMounts:
- name: varlibcontainers
mountPath: /var/lib/containers
securityContext:
privileged: true
volumes:
- name: varlibcontainers
emptyDir: {}
+23
View File
@@ -0,0 +1,23 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: j7s-git-clone-hash
namespace: j7s-ci
spec:
workspaces:
- name: output
- name: ssh-directory
params:
- name: url
- name: hash
steps:
- image: harbor.internal.jpace121.net/gitssh:latest
script: |
set -x
cp -r $(workspaces.ssh-directory.path) ~/.ssh
chmod 700 ~/.ssh
chmod -R 400 ~/.ssh/*
git clone $(params.url) $(workspaces.output.path)
cd $(workspaces.output.path)
git checkout $(params.hash)
+21
View File
@@ -0,0 +1,21 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: j7s-git-clone
namespace: j7s-ci
spec:
workspaces:
- name: output
- name: ssh-directory
params:
- name: url
- name: branch
steps:
- image: harbor.internal.jpace121.net/gitssh:latest
script: |
set -x
cp -r $(workspaces.ssh-directory.path) ~/.ssh
chmod 700 ~/.ssh
chmod -R 400 ~/.ssh/*
git clone --single-branch --branch $(params.branch) $(params.url) $(workspaces.output.path)
+25
View File
@@ -0,0 +1,25 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: j7s-ros-clone
namespace: j7s-ci
spec:
workspaces:
- name: output
- name: ssh-directory
params:
- name: url
- name: branch
- name: repos-file
steps:
- image: harbor.internal.jpace121.net/vcs:latest
script: |
set -x
cp -r $(workspaces.ssh-directory.path) ~/.ssh
chmod 700 ~/.ssh
chmod -R 400 ~/.ssh/*
git clone --single-branch --branch $(params.branch) $(params.url) $(workspaces.output.path)
cd $(workspaces.output.path)
mkdir src
vcs import src < $(params.repos-file)
+8
View File
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- j7s-ansible-build.yaml
- j7s-buildah.yaml
- j7s-git-clone-hash.yaml
- j7s-git-clone.yaml
- j7s-ros-clone.yaml