All checks were successful
Amarillo/amarillo-gitea/amarillo-core/pipeline/head This commit looks good
93 lines
3.7 KiB
Groovy
93 lines
3.7 KiB
Groovy
pipeline {
|
|
agent any
|
|
environment {
|
|
GITEA_CREDS = credentials('AMARILLO-JENKINS-GITEA-USER')
|
|
TWINE_REPO_URL = "https://git.gerhardt.io/api/packages/amarillo/pypi"
|
|
PLUGINS_REPO_URL = "git.gerhardt.io/api/packages/amarillo/pypi/simple"
|
|
DOCKER_REGISTRY_URL = 'https://git.gerhardt.io'
|
|
OWNER = 'amarillo'
|
|
IMAGE_NAME = 'amarillo'
|
|
AMARILLO_DISTRIBUTION = '0.1'
|
|
TAG = "${AMARILLO_DISTRIBUTION}.${BUILD_NUMBER}"
|
|
PLUGINS = 'amarillo-metrics amarillo-enhancer'
|
|
DEPLOY_WEBHOOK_URL = 'http://amarillo.mfdz.de:8888/mitanand'
|
|
DEPLOY_SECRET = credentials('AMARILLO-JENKINS-DEPLOY-SECRET')
|
|
}
|
|
stages {
|
|
stage('Echo environment variables'){
|
|
steps {
|
|
echo "BRANCH_NAME: ${BRANCH_NAME}"
|
|
echo "JOB_NAME: ${JOB_NAME}"
|
|
echo "BRANCH_IS_PRIMARY ${BRANCH_IS_PRIMARY}"
|
|
echo "TAG_NAME: ${TAG_NAME}"
|
|
}
|
|
}
|
|
stage('Build docker image') {
|
|
steps {
|
|
echo 'Building image'
|
|
script {
|
|
docker.build("${OWNER}/${IMAGE_NAME}:${TAG}",
|
|
//--no-cache to make sure plugins are updated
|
|
"-t ${OWNER}/${IMAGE_NAME}:latest --no-cache --build-arg='PACKAGE_REGISTRY_URL=${PLUGINS_REPO_URL}' --build-arg='PLUGINS=${PLUGINS}' --secret id=AMARILLO_REGISTRY_CREDENTIALS,env=GITEA_CREDS .")
|
|
}
|
|
}
|
|
}
|
|
// stage('Run tests on image'){
|
|
// steps{
|
|
// script {
|
|
// docker.image("${OWNER}/${IMAGE_NAME}:${TAG}").inside(
|
|
// "--name amarillo -p 8000:80 -e MODULE_NAME=amarillo.app.main -e MAX_WORKERS=1 -e ADMIN_TOKEN=test -e RIDE2GO_TOKEN=test -e METRICS_USER=test -e METRICS_PASSWORD=test -e TZ=Europe/Berlin -v ${pwd()}/data:/app/data"
|
|
// ){
|
|
// // TODO: wait until the API is up
|
|
// c -> sh script: """
|
|
// sleep 15
|
|
// echo Testing...
|
|
// python -m pytest
|
|
// """
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
stage('Push image to container registry') {
|
|
steps {
|
|
echo 'Pushing image to registry'
|
|
script {
|
|
docker.withRegistry(DOCKER_REGISTRY_URL, 'AMARILLO-JENKINS-GITEA-USER'){
|
|
docker.image("${OWNER}/${IMAGE_NAME}:${TAG}").push()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Notify CD script') {
|
|
steps {
|
|
echo 'Triggering deploy webhook'
|
|
script {
|
|
def response = httpRequest contentType: 'APPLICATION_JSON',
|
|
httpMode: 'POST', requestBody: '{}', authentication: 'AMARILLO-JENKINS-DEPLOY-SECRET',
|
|
url: "${DEPLOY_WEBHOOK_URL}"
|
|
|
|
println("Status: ${response.status}")
|
|
println("Response: ${response.content}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
echo 'This will always run'
|
|
}
|
|
success {
|
|
echo 'This will run only if successful'
|
|
}
|
|
failure {
|
|
echo 'This will run only if failed'
|
|
}
|
|
unstable {
|
|
echo 'This will run only if the run was marked as unstable'
|
|
}
|
|
changed {
|
|
echo 'This will run only if the state of the Pipeline has changed'
|
|
echo 'For example, if the Pipeline was previously failing but is now successful'
|
|
}
|
|
}
|
|
} |