mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 12:30:41 +01:00
Fix the rerun functionality when using an inventory from a git repo
Changed the way the cloneInventoryRepo() function handles git repositories: The function will now try to pull the git repo if it can be pulled, else it will be cloned. This behaviour is based on what is done in the updateRepository() function Renamed the file from "LobalJob_inventory.go" to "LocalJob_inventory.go"
This commit is contained in:
parent
59ef3f8a12
commit
70f4b7397e
@ -1,13 +1,14 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"github.com/ansible-semaphore/semaphore/db"
|
||||
"github.com/ansible-semaphore/semaphore/db_lib"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"path"
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -61,9 +62,20 @@ func (t *LocalJob) cloneInventoryRepo() error {
|
||||
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 {
|
Loading…
Reference in New Issue
Block a user