Compare commits

...

7 Commits

Author SHA1 Message Date
deployer3000 5474ca1ffa Merge pull request 'rc' (#3) from rc into master
Reviewed-on: http://192.168.2.61/deployer3000/prometheus-exporter/pulls/3
2025-02-24 10:37:29 +03:00
yuobrezkov 1efe122edf Fixed brackets in jenkinsfile 2
test-org/prometheus-exporter/pipeline/pr-master This commit looks good Details
2025-02-21 14:35:54 +03:00
yuobrezkov df8b603a01 Fixed brackets in jenkinsfile
test-org/prometheus-exporter/pipeline/pr-master There was a failure building this commit Details
2025-02-21 14:32:44 +03:00
yuobrezkov 6ad1b23359 Some changes in dockerfile and jenkinsfile
test-org/prometheus-exporter/pipeline/pr-master There was a failure building this commit Details
2025-02-21 14:27:24 +03:00
yuobrezkov beecc698f0 Deleted removing package/ from post pipeline 2025-02-21 12:18:18 +03:00
yuobrezkov 358e6cf509 Changed owner to repo 2025-02-21 12:16:57 +03:00
yuobrezkov 2b33015277 Added Jenkinsfile 2025-02-21 12:16:38 +03:00
2 changed files with 82 additions and 1 deletions

View File

@ -5,6 +5,7 @@ RUN apt update && apt install -y musl-tools
RUN rustup target add x86_64-unknown-linux-musl RUN rustup target add x86_64-unknown-linux-musl
COPY . . COPY . .
RUN cargo test
RUN cargo build --release --target=x86_64-unknown-linux-musl RUN cargo build --release --target=x86_64-unknown-linux-musl
FROM alpine:latest FROM alpine:latest
@ -14,4 +15,4 @@ COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/exporter /app/
RUN apk add --no-cache ca-certificates RUN apk add --no-cache ca-certificates
CMD ["/app/exporter"] ENTRYPOINT ["/app/exporter"]

80
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,80 @@
pipeline {
agent any
environment {
REGISTRY_NAME = 'registry.entcor/trust-module'
IMAGE_NAME = "prometheus-exporter"
GITEA_REPOSITORY_URL = "http://git.entcor/api/v1/repos/"
}
stages {
stage('Init variables') {
when {
expression { env.CHANGE_BRANCH?.startsWith('rc') }
}
steps {
script {
env.IMAGE_TAG = sh(script: "git describe --tags --abbrev=0", returnStdout: true).trim()
}
}
}
stage('Build tagged image and run tests') {
when {
expression { env.CHANGE_BRANCH?.startsWith('rc') }
}
steps {
script {
try {
def image = docker.build("${env.IMAGE_NAME}:${env.IMAGE_TAG}")
sh "docker tag ${env.IMAGE_NAME}:${env.IMAGE_TAG} ${env.REGISTRY_NAME}/${env.IMAGE_NAME}:${env.IMAGE_TAG}"
} catch (Exception e) {
error("Tests failed: ${e.message}")
}
}
}
}
stage ('Push docker image to registry') {
when {
expression { env.CHANGE_BRANCH?.startsWith('rc') }
}
steps {
script {
docker.withRegistry('https://registry.entcor/harbor/', 'harbor-credentials-id') {
docker.image("${env.REGISTRY_NAME}/${env.IMAGE_NAME}:${env.IMAGE_TAG}").push()
}
}
}
}
}
post {
always {
script {
echo "Cleaning up workspace..."
sh "rm -rf ${env.WORKSPACE}/rc/ || true"
}
}
success {
script {
if (env.CHANGE_BRANCH?.startsWith('rc')) {
echo "Attempting to merge PR ${env.CHANGE_ID} into master..."
withCredentials([usernamePassword(credentialsId: 'gitea_creds', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_PASS')]) {
def prId = env.CHANGE_ID
sh """
curl -X POST \
-u "${GITEA_USER}:${GITEA_PASS}" \
-H "Content-Type: application/json" \
-d '{"do":"merge"}' \
http://git.entcor/api/v1/repos/deployer3000/prometheus-exporter/pulls/${prId}/merge
"""
echo "PR ${prId} merged successfully into master!"
}
}
}
}
failure {
echo "Pipeline failed. Check the logs for details."
}
aborted {
echo "Pipeline was aborted."
}
}
}