Compare commits
7 Commits
a79ae2d50f
...
jenkins-pi
Author | SHA1 | Date | |
---|---|---|---|
1de32691c6 | |||
f05d3940fa | |||
023daf1d4b | |||
e91273888a | |||
247798abc8 | |||
600b5aeba8 | |||
c9b1dac864 |
34
.jenkins/Jenkinsfile
vendored
34
.jenkins/Jenkinsfile
vendored
@ -10,6 +10,7 @@ pipeline {
|
|||||||
CLIENT_ID = 'c302726f-fafb-4143-94c1-67a70975574a'
|
CLIENT_ID = 'c302726f-fafb-4143-94c1-67a70975574a'
|
||||||
DOCKER_REGISTRY_URL = 'marcin00.azurecr.io'
|
DOCKER_REGISTRY_URL = 'marcin00.azurecr.io'
|
||||||
DOCKER_IMAGE = "${DOCKER_REGISTRY_URL}/user-microservice:${GIT_COMMIT}"
|
DOCKER_IMAGE = "${DOCKER_REGISTRY_URL}/user-microservice:${GIT_COMMIT}"
|
||||||
|
DEPLOY_REPO = 'https://gitea.marcin00.pl/pikram/user-microservice-deploy.git'
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@ -45,5 +46,38 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Commit new version to GitOps repo') {
|
||||||
|
steps {
|
||||||
|
container('git') {
|
||||||
|
sh '''
|
||||||
|
git config --global user.name "jenkins[bot]"
|
||||||
|
git config --global user.email "jenkins@marcin00.pl"
|
||||||
|
'''
|
||||||
|
sh 'git clone ${DEPLOY_REPO} --branch jenkins-kubernetes'
|
||||||
|
dir('user-microservice-deploy') {
|
||||||
|
sh '''
|
||||||
|
# Podmień tag obrazu w pliku deploy.yaml
|
||||||
|
awk -v commit="ssh-creds-id$GIT_COMMIT" '
|
||||||
|
$0 ~ /name:[[:space:]]*api/ { in_api_container = 1; print; next }
|
||||||
|
in_api_container && $0 ~ /^[[:space:]]*image:[[:space:]]*/ {
|
||||||
|
sub(/:[^:[:space:]]+$/, ":" commit)
|
||||||
|
in_api_container = 0
|
||||||
|
print
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
' deploy.yaml > deploy.tmp && mv deploy.tmp deploy.yaml
|
||||||
|
'''
|
||||||
|
sh 'git commit -am "JENKINS: Changed deployed version to $GIT_COMMIT"'
|
||||||
|
sshagent(['gitea-deploy-key']) {
|
||||||
|
sh '''
|
||||||
|
git remote set-url origin ssh://git@srv22.mikr.us:20343/pikram/user-microservice-deploy.git
|
||||||
|
git push
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,16 @@ spec:
|
|||||||
- name: workspace-volume
|
- name: workspace-volume
|
||||||
mountPath: /home/jenkins/agent
|
mountPath: /home/jenkins/agent
|
||||||
|
|
||||||
|
- name: git
|
||||||
|
image: alpine/git:latest
|
||||||
|
command:
|
||||||
|
- cat
|
||||||
|
tty: true
|
||||||
|
workingDir: /home/jenkins/agent
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace-volume
|
||||||
|
mountPath: /home/jenkins/agent
|
||||||
|
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/os: linux
|
kubernetes.io/os: linux
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ from flask import Blueprint, jsonify, request, abort
|
|||||||
from flask_jwt_extended import create_access_token, set_access_cookies, jwt_required, \
|
from flask_jwt_extended import create_access_token, set_access_cookies, jwt_required, \
|
||||||
verify_jwt_in_request, get_jwt_identity, unset_jwt_cookies, get_jwt
|
verify_jwt_in_request, get_jwt_identity, unset_jwt_cookies, get_jwt
|
||||||
from models import db, RevokedToken, User
|
from models import db, RevokedToken, User
|
||||||
|
import os
|
||||||
from utils import admin_required, validate_access, get_user_or_404
|
from utils import admin_required, validate_access, get_user_or_404
|
||||||
from werkzeug.security import check_password_hash, generate_password_hash
|
from werkzeug.security import check_password_hash, generate_password_hash
|
||||||
|
|
||||||
@ -110,3 +111,10 @@ def user_logout():
|
|||||||
response = jsonify({"msg": "User logged out successfully."})
|
response = jsonify({"msg": "User logged out successfully."})
|
||||||
unset_jwt_cookies(response)
|
unset_jwt_cookies(response)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@user_bp.route('/version', methods=['GET'])
|
||||||
|
def version():
|
||||||
|
return jsonify({
|
||||||
|
"version": os.getenv("APP_VERSION", "unknown"),
|
||||||
|
"build_time": os.getenv("BUILD_DATE", "unknown")
|
||||||
|
})
|
Reference in New Issue
Block a user