43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
|
|
pipeline {
|
||
|
|
agent any
|
||
|
|
environment {
|
||
|
|
REGISTRY = 'registry.bstein.dev'
|
||
|
|
IMAGE = 'infra/harbor-arm-build'
|
||
|
|
}
|
||
|
|
stages {
|
||
|
|
stage('Checkout') {
|
||
|
|
steps {
|
||
|
|
git credentialsId: 'gitea-pat', url: 'https://scm.bstein.dev/bstein/harbor-arm-build.git'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
stage('Build image') {
|
||
|
|
steps {
|
||
|
|
sh '''
|
||
|
|
cat > app.sh <<'APP'
|
||
|
|
#!/usr/bin/env bash
|
||
|
|
echo "hello harbor arm build $(date)"
|
||
|
|
APP
|
||
|
|
chmod +x app.sh
|
||
|
|
cat > Dockerfile <<'DOCKER'
|
||
|
|
FROM alpine:3.20
|
||
|
|
COPY app.sh /usr/local/bin/app.sh
|
||
|
|
RUN chmod +x /usr/local/bin/app.sh
|
||
|
|
ENTRYPOINT ["/usr/local/bin/app.sh"]
|
||
|
|
DOCKER
|
||
|
|
docker build -t $REGISTRY/$IMAGE:latest .
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
stage('Push image') {
|
||
|
|
steps {
|
||
|
|
withCredentials([usernamePassword(credentialsId: 'harbor-robot', usernameVariable: 'HUSER', passwordVariable: 'HPASS')]) {
|
||
|
|
sh '''
|
||
|
|
echo "$HPASS" | docker login -u "$HUSER" --password-stdin $REGISTRY
|
||
|
|
docker push $REGISTRY/$IMAGE:latest
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|