I have two repositories in gitlab first one with the main project, the
second one with autotests. There is Jenkins pipeline, with the following
configurations:
*Build triggers:*
*Poll SCM Schedule: * * * * **
*Definition: Pipeline script from SCM*
*SCM: Git*
*Repositories:*
* Repository URL: https://gitlab.com/App/Application.git
<https://gitlab.com/App/Application.git>*
* Credentials: Creds/*******
*Branches to build:*
* Branch Specifier (blank for 'any'): */master*
*Repository browser: Auto*
*Script Path: pipelines/Jenkinsfile*
The contents of Jenkinsfile:
try {
node('Slave') {
stage('Build') {
dir('Backend') {
git url: "https://$gitRepo", branch: 'master', credentialsId:
gitlabCredentialsId
def commitHash = sh(returnStdout: true, script: 'git rev-parse
--short HEAD').trim()
version = "${getDateTime()}-$commitHash"
sh 'chmod +x gradlew && ./gradlew clean build --no-daemon'
withCredentials([usernamePassword(credentialsId:
gitlabCredentialsId,
passwordVariable: 'GITLAB_PASSWORD', usernameVariable:
'GITLAB_USERNAME')]) {
sh("docker login $registryName -u $GITLAB_USERNAME -p
$GITLAB_PASSWORD")
}
docker.withRegistry("https://$registryName") {
def image = docker.build(imageName)
image.push(version)
image.push('latest')
}
sh 'docker system prune -af || true'
}
}
stage('Integration tests') {
dir('Autotests') {
try {
url: "https://$autotestsGitRepo", branch: 'master',
credentialsId: gitlabCredentialsId
withCredentials([usernamePassword(credentialsId:
gitlabCredentialsId,
passwordVariable: 'GITLAB_PASSWORD',
usernameVariable: 'GITLAB_USERNAME')]) {
sh("docker login $registryName -u $GITLAB_USERNAME -p
$GITLAB_PASSWORD; docker-compose pull backend; docker-compose up -d")
waitUntilAppIsUp(localhost)
sh('./gradlew clean test')
}
} finally {
sh("docker-compose down")
step([$class: 'JUnitResultArchiver', keepLongStdio: true,
testResults: 'build/test-results/test/*.xml'])
}
}
}
stage('Staging deployment') {
withCredentials([usernamePassword(credentialsId:
gitlabCredentialsId,
passwordVariable: 'GITLAB_PASSWORD', usernameVariable:
'GITLAB_USERNAME')]) {
sshagent(credentials: [sshInstanceCredentialsId]) {
dir('Backend') {
sh "scp -o StrictHostKeyChecking=no docker-compose.yml
$instanceHost:"
sh "ssh -o StrictHostKeyChecking=no $instanceHost
'docker login $registryName -u $GITLAB_USERNAME -p $GITLAB_PASSWORD;
docker-compose pull backend; docker-compose up -d'"
waitUntilAppIsUp(stagingHost)
}
}
}
}
}
} catch (e) {
throw e
}
*When I merge into the master of main Application project, pipeline starts
in a minute and passes or fails one time as it should be. But when I merge
into the master of Autotests repository, pipeline starts in a minute then
it starts in a minute one more time then it starts in a minute over and
over again while pipeline is still running. How to fix it?*
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/9b6334d8-6657-47b7-a90e-7e6f86946673%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.