Merge pull request #2151 from vaz-ar/fix_rerun

Fix the rerun functionality when using an inventory from a git repo
This commit is contained in:
Denis Gukov 2024-07-02 00:27:09 +05:00 committed by GitHub
commit 2dc2e3e191
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,13 +1,14 @@
package tasks package tasks
import ( import (
"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/db_lib"
log "github.com/sirupsen/logrus"
"os" "os"
"path" "path"
"strconv" "strconv"
"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/db_lib"
log "github.com/sirupsen/logrus"
"github.com/ansible-semaphore/semaphore/util" "github.com/ansible-semaphore/semaphore/util"
) )
@ -61,9 +62,20 @@ func (t *LocalJob) cloneInventoryRepo() error {
Client: db_lib.CreateDefaultGitClient(), Client: db_lib.CreateDefaultGitClient(),
} }
err := repo.Clone() // Try to pull the repo before trying to clone it
if repo.CanBePulled() {
err := repo.Pull()
if err == nil {
return nil
}
}
return err err := os.RemoveAll(repo.GetFullPath())
if err != nil {
return err
}
return repo.Clone()
} }
func (t *LocalJob) installStaticInventory() error { func (t *LocalJob) installStaticInventory() error {