Browse Source

Update 'Jenkinsfile'

master
mh 5 months ago
parent
commit
fd9ea41c4b
  1. 38
      Jenkinsfile

38
Jenkinsfile

@ -1,11 +1,19 @@
pipeline { pipeline {
agent any agent any
environment {
GITEA_CREDS = 'test'
GITEA_REPO_URL = 'https://github.com/mh-lornejad/jenkins-test3.git'
GITEA_TOKEN = 'your-gitea-token'
MAIN_BRANCH = 'token'
}
stages { stages {
stage('Clone the repo') { stage('Clone the repo') {
steps { steps {
echo "Clone the repo" echo "Clone the repo"
sh "rm -fr jenkins-test3" sh "rm -fr jenkins-test3"
git branch: 'main', credentialsId: 'test', url: 'https://github.com/mh-lornejad/jenkins-test3.git' git branch: "${env.MAIN_BRANCH}", credentialsId: "${env.GITEA_CREDS}", url: "${env.GITEA_REPO_URL}"
} }
} }
stage('Code Analysis') { stage('Code Analysis') {
@ -41,4 +49,32 @@ pipeline {
} }
} }
} }
post {
always {
script {
def status = currentBuild.result == 'SUCCESS' ? 'success' : 'failure'
def state = status == 'success' ? 'success' : 'failure'
def description = "Jenkins build ${status}"
def commitSha = env.GIT_COMMIT
httpRequest(
url: "${env.GITEA_REPO_URL}/statuses/${commitSha}",
httpMode: 'POST',
customHeaders: [
[name: 'Content-Type', value: 'application/json'],
[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"]
],
requestBody: """
{
"state": "${state}",
"target_url": "${env.BUILD_URL}",
"description": "${description}",
"context": "continuous-integration/jenkins"
}
"""
)
}
}
}
} }

Loading…
Cancel
Save