question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
Is it possible to create a system-wide global variable / semaphore / mutex in C++ on Linux? Here's the reason: I've got a system that often runs multiple copies of the same software on unrelated data. It's common to have 4 jobs, each running the same software. The software has a small section where it creates a huge g...
You can use a named semaphore if you can get all the processes to agree on a common name. A named semaphore is identified by a name of the form /somename; that is, a null-terminated string of up to NAME_MAX-4 (i.e., 251) characters consisting of an initial slash, followed by one or more characters, none of wh...
Semaphore
32,338,732
19
POSIX anonymous semaphores allow me to create and use a semaphore in shared memory. This works great, because this means other processes that shouldn't have access to the semaphore don't have access to the semaphore. In addition, it's easy to incorporate into existing structures. Does Windows offer something like this?...
NO. You cannot specify a desired starting address for semaphore with WindowsAPI. The document only states three ways to use semaphore between processes. A process can specify the name of a semaphore object in a call to the OpenSemaphore or CreateSemaphoreEx function besides the two ways you pointed.
Semaphore
73,643,031
17
I'm working on an implementation of the "Fair Barbershop" problem in Ruby. This is for a class assignment, but I'm not looking for any handouts. I've been searching like crazy, but I cannot seem to find a Ruby implementation of Semaphores that mirror those found in C. I know there is Mutex, and that's great. Single i...
If you are using JRuby, you can import semaphores from Java as shown in this article. require 'java' java_import 'java.util.concurrent.Semaphore' SEM = Semaphore.new(limit_of_simultaneous_threads) SEM.acquire #To decrement the number available SEM.release #To increment the number available
Semaphore
5,478,789
17
I'm trying to understand the similarities and differences between named and unnamed semaphore so my google searches yielded me this. I had a question about the wording on the page though, it says: Unnamed semaphores might be usable by more than one process Named semaphores are sharable by several processes Do those t...
Think in terms of who can access the semaphore. Unnamed semaphores (lacking any name or handle to locate them) must exist in some pre-existing, agreed upon memory location. Usually that is (1) shared memory (inherited by children after fork) in the case of child processes; or (2) shared memory, global variable or the ...
Semaphore
13,145,885
16
In a class, we've had to use semaphores to accomplish work with threads. The prototype (and header file) of sem_init is the following: int sem_init(sem_t *sem, int pshared, unsigned int value); but I don't understand what the value variable is used for. According to opengroup.org: value is an initial value to set t...
Semaphore value represents the number of common resources available to be shared among the threads. If the value is greater than 0, then the thread calling sem_wait need not wait. It just decrements the value by 1 and proceeds to access common resource. sem_post will add a resource back to the pool. So it increments th...
Semaphore
9,369,873
16
I need to create two child processes each of which calls execvp ater being forked, and the executables share POSIX semaphores between them. Do I need to create a shared memory or just implement named semaphores? I got two answers from the following links: Do forked child processes use the same semaphore? How to share...
Do I need to create a shared memory or just implement named semaphores? Either approach will work. Pick one and go with it - though I personally prefer named semaphores because you don't have to deal with memory allocation and with setting up the shared memory segments. The interface for creating and using named se...
Semaphore
32,205,396
16
i have two methods -(void) a { @synchronized(self) { // critical section 1 } } -(void) b { @synchronized(self) { // critical section 2 } } now my question is if a thread is in critical section 1. will the critical section 2 be locked for other threads or other threads can access critical sec...
Critical section 2 will be blocked to other threads, as well, since you're synchronizing on the same object (self).
Semaphore
2,810,459
16
I need two threads to progress in a "tick tock" pattern. When implmented with a semaphore this looks fine: Semaphore tick_sem(1); Semaphore tock_sem(0); void ticker( void ) { while( true ) { P( tick_sem ); do_tick(); V( tock_sem ); } } void tocker( void ) { while( true ) { P( t...
A Mutex is not simply just a binary semaphore, it also has the limitation that only the locking thread is allowed to unlock it. You are breaking that rule. Edit: From MSDN: The ReleaseMutex function fails if the calling thread does not own the mutex object. From some site that google turned up for pthread_mutex_unl...
Semaphore
6,804,044
16
I am trying to port a project (from linux) that uses Semaphores to Mac OS X however some of the posix semaphores are not implemented on Mac OS X The one that I hit in this port is sem_timedwait() I don't know much about semaphores but from the man pages sem_wait() seems to be close to sem_timedwait and it is implemente...
It's likely that the timeout is important to the operation of the algorithm. Therefore just using sem_wait() might not work. You could use sem_trywait(), which returns right away in all cases. You can then loop, and use a sleep interval that you choose, each time decrementing the total timeout until you either run out ...
Semaphore
641,126
16
I want some clarification regarding mutex and semaphore. My question is, What mutex actually do when a thread tries to enter a region locked by a mutex, a. it waits for the lock to be released? or b. it goes to sleep until the lock is released. In that case how it is wake up again when the lock is released? Sam...
When a thread tries to acquire a lock on a mutex, if that mutex is already held then typically it will use a call to the OS kernel to indicate that it is waiting, and then when the thread that currently holds the lock unlocks the mutex then it will make a call to the OS kernel to wake one of the waiting threads. The sa...
Semaphore
9,427,276
15
In a graduate class, we've had to use semaphores to accomplish work with threads. We were directed to use sem_init along with a bunch of other sem_* procedure but we were not given much information about the details of each of these sem_* methods. The prototype (and header file) of sem_init is the following: #include ...
The GLIBC version of sem_init (what you get if you man sem_init on Linux) has this to say: "The pshared argument indicates whether this semaphore is to be shared between the threads of a process, or between processes." So pshared is a boolean value: in practice meaningful values passed to it are false (0) and tru...
Semaphore
1,291,566
15
I'm designing a .net core web api that consumes an external api that I do not control. I've found some excellent answers on stack overflow that allowed me to throttle my requests to this external API while in the same thread using semaphoreslim. I'm wondering how best to extend this throttling to be application wide ...
Conceptual questions SemaphoreSlim is thread-safe so there are no thread-safety or locking concerns about using it as a parallelism throttle across multiple threads. HttpMessageHandlers are indeed an outbound middleware mechanism to intercept calls placed through HttpClient. So they are an ideal way to apply paralleli...
Semaphore
52,044,186
15
So I am getting the error: "undefined reference to sem_open()" even though I have included the <semaphore.h> header. The same thing is happening for all my pthread function calls (mutex, pthread_create, etc). Any thoughts? I am using the following command to compile: g++ '/home/robin/Desktop/main.cpp' -o '/home/robi...
You need link with pthread lib, using -lpthread option.
Semaphore
4,916,881
15
I have a script in python which uses a resource which can not be used by more than a certain amount of concurrent scripts running. Classically, this would be solved by a named semaphores but I can not find those in the documentation of the multiprocessing module or threading . Am I missing something or are named semaph...
I suggest a third party extension like these, ideally the posix_ipc one -- see in particular the semaphore section in the docs. These modules are mostly about exposing the "system V IPC" (including semaphores) in a unixy way, but at least one of them (posix_ipc specifically) is claimed to work with Cygwin on Windows (I...
Semaphore
2,798,727
15
(I think that) the consensus number for a mutex is 2. What is the consensus number for semaphores (like in pthread_sem_*)? What is the consensus number for condition variables (like in pthread_cond_*)?
The consensus number for a mutex would be 1. It's trivially clear that a mutex will be wait-free for a single thread. From its definition, it's also clear that a mutex is no longer wait-free for two threads. The consensus number therefore is >=1 and <2, so it must be 1. Likewise, other synchronization mechanisms that w...
Semaphore
773,212
14
From the Java java.util.concurrent.Semaphore docs it wasn't quite clear to me what happens if semaphore.acquire() blocks the thread and later gets interrupted by an InterruptedException. Has the semaphore value been decreased and so is there a need to release the semaphore? Currently I am using code like this: try { ...
call release() when an InterruptedException occurs during acquire() ? You should not. If .acquire() is interrupted, the semaphore is not acquired, so likely should not release it. Your code should be // use semaphore to limit number of parallel threads semaphore.acquire(); try { doMyWork(); } finally { semaphore...
Semaphore
12,104,978
14
I am working on a MATLAB project where I would like to have two instances of MATLAB running in parallel and sharing data. I will call these instances MAT_1 and MAT_2. More specifically, the architecture of the system is: MAT_1 processes images sequentially, reading them one by one using imread, and outputs the result ...
I would approach this using semaphores; in my experience the PCT is unreasonably slow at synchronization. dfacto (another answer) has a great implementation of semaphores for MATLAB, however it will not work on MS Windows; I improved on that work so that it would. The improved work is here: http://www.mathworks.com/ma...
Semaphore
6,415,283
14
I wanted to know what would be better/faster to use POSIX calls like pthread_once() and sem_wait() or the dispatch_* functions, so I created a little test and am surprised at the results (questions and results are at the end). In the test code I am using mach_absolute_time() to time the calls. I really don’t care that...
sem_wait() and sem_post() are heavy weight synchronization facilities that can be used between processes. They always involve round trips to the kernel, and probably always require your thread to be rescheduled. They are generally not the right choice for in-process synchronization. I'm not sure why the named variants ...
Semaphore
3,640,853
14
The true power of semaphore is : Limits the number of threads that can access a resource or pool of resources concurrently That is understood and clear. But I never got a chance to play with the overload of Wait which accepts a timeout integer, however - this seems to allow multiple threads get into the critical s...
You need to check the return value of the wait. The Timeout based wait will try for 2 seconds to take the mutex then return. You need to check if the return value is true (i.e you have the mutex) or not. Edit: Also keep in mind that the timeout based wait will return immediately if the semaphore is available, so you ...
Semaphore
32,624,497
14
Can the semaphore be lower than 0? I mean, say I have a semaphore with N=3 and I call "down" 4 times, then N will remain 0 but one process will be blocked? And same the other way, if in the beginning I call up, can N be higher than 3? Because as I see it, if N can be higher than 3 if in the beginning I call up couple o...
(Using the terminology from java.util.concurrent.Semaphore given the Java tag. Some of these details are implementation-specific. I suspect your "down" is the Java semaphore's acquire() method, and your "up" is release().) Yes, your last call to acquire() will block until another thread calls release() or your thread i...
Semaphore
1,221,322
14
Can I add more permit to a semaphore in Java? Semaphore s = new Semaphore(3); After this somewhere in the code i want to change the permits to 4. Is this possible?
Yes. The release method (confusingly named imo) can be used to increment permits since, from the docs: There is no requirement that a thread that releases a permit must have acquired that permit by calling acquire. Correct usage of a semaphore is established by programming convention in the application. In other w...
Semaphore
9,789,073
14
In one of our classes, we make heavy use of SemaphoreSlim.WaitAsync(CancellationToken) and cancellation of it. I appear to have hit a problem when a pending call to WaitAsync is cancelled shortly after a call to SemaphoreSlim.Release()(by shortly, I mean before the ThreadPool has had a chance to process a queued item),...
SemaphoreSlim was changed in .NET 4.5.1 .NET 4.5 Version of WaitUntilCountOrTimeoutAsync method is: private async Task<bool> WaitUntilCountOrTimeoutAsync(TaskNode asyncWaiter, int millisecondsTimeout, CancellationToken cancellationToken) { [...] // If the await completed synchronously, we still hold the lock....
Semaphore
21,019,895
14
In the man page it appears that even if you initialise a semaphore to a value of one: sem_init(&mySem, 0, 1); It could still be incremented to a value greater than 1 with multiple calls to sem_post(&mySem); But in this code example the comment seems to think differently: sem_init(&mutex, 0, 1); /* initialize mut...
If you want a strictly binary semaphore on Linux, I suggest building one out of mutexes and condition variables. struct binary_semaphore { pthread_mutex_t mutex; pthread_cond_t cvar; bool v; }; void mysem_post(struct binary_semaphore *p) { pthread_mutex_lock(&p->mutex); if (p->v) abort(); /...
Semaphore
7,478,684
14
I have the following Java code: import java.util.concurrent.*; class Foo{ static Semaphore s = new Semaphore(1); public void fun(final char c, final int r){ new Thread(new Runnable(){ public void run(){ try{ s.acquire(r); System.out....
The basic problem is that acquire(int permits) does not guarantee that all permits will be grabbed at once. It could acquire fewer permits and then block while waiting for the rest. Let's consider your code. When, say, three permits become available there's nothing to guarantee that they will be given to thread C. They...
Semaphore
7,743,203
13
I need to check my algorithm of solving the dining philosopher problem if it guarantees that all of the following are satisfied or not: No possibility of deadlock. No possibility of starvation. I am using the semaphore on the chopsticks to solve the problem. Here is my code (the algorithm): while(true) { // He is...
Definitions. A philosopher is enabled iff he is not waiting for an unavailable semaphore. An execution is an infinite sequence of steps taken by enabled philosophers. An execution is strongly fair iff every philosopher enabled infinitely often takes infinitely many steps. A dining philosophers solution is starvation-fr...
Semaphore
8,274,098
13
I'm late to the party, but I recently learned about SemaphoreSlim: I used to use lock for synchronous locking, and a busy boolean for asynchronous locking. Now I just use SemaphoreSlim for everything. private SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1); private void DoStuff() { semaphoreSlim.Wait(); ...
Here are the advantages of the lock over the SemaphoreSlim: The lock is reentrant, while the SemaphoreSlim is not. So programming with the lock is more forgiving. In case there is a rare path in your app where you are acquiring the same lock twice, the lock will acquire it successfully, while the SemaphoreSlim will de...
Semaphore
74,522,878
13
What are the differences between the functions included in <semaphore.h> and <sys/sem.h>? Does exist a situation where is better to use a header or the other?
<sys/sem.h> provides the interface for XSI (originally Unix System V) semaphores. These are not part of the base POSIX standard (they're in the XSI option which is largely for traditional Unix compatibility) and while they are not considered obsolescent/deprecated yet, many programmers consider them deprecated, and POS...
Semaphore
11,058,045
12
I'm trying to implement a pool of workers in Go. The go-wiki (and Effective Go in the Channels section) feature excellent examples of bounding resource use. Simply make a channel with a buffer that's as large as the worker pool. Then fill that channel with workers, and send them back into the channel when they're do...
I would do it the other way round. Instead of spawning many goroutines (which still require a considerable amount of memory) and use a channel to block them, I would model the workers as goroutines and use a channel to distribute the work. Something like this: package main import ( "fmt" "sync" ) type Task st...
Semaphore
23,837,368
12
I am not an advanced developer. I'm just trying to get a hold on the task library and just googling. I've never used the class SemaphoreSlim so I would like to know what it does. Here I present code where SemaphoreSlim is used with async & await but which I do not understand. Could someone help me to understand the cod...
why 10 is passing to SemaphoreSlim constructor. They are using SemaphoreSlim to limit to 10 tasks at a time. The semaphore is "taken" before each task is started, and each task "releases" it when it finishes. For more about semaphores, see MSDN. they can use simply Task.Delay(3000) but why they use await here. Task...
Semaphore
19,998,779
12
Does anyone know how .NET handles a timeout on a call to Semaphore.WaitOne(timeout)? I'd expect a TimeoutException, but the MSDN documentation doesn't list this in the list of expected exceptions, and I can't seem to find it documented anywhere.
The method will return false if it times out, and true if it returns a signal: if (mySemaphore.WaitOne(1000)) { // signal received } else { // wait timed out }
Semaphore
1,431,349
12
For an OS class, I currently have to create a thread-safe queue in the linux kernel that one interacts with using syscalls. Now for the critical sections my gut feeling is that I would want to use the mutex_lock and mutex_unlock functions in the mutex.h header. However, I was told that I could instead use a binary sema...
In absence of empirical evidence, I'd quote from the book Linux Kernel Development It (i.e. mutex) behaves similar to a semaphore with a count of one, but it has a simpler interface, more efficient performance, and additional constraints on its use. Additionally, there are many constraints that apply to mutexes b...
Semaphore
40,291,858
11
Are the P() and V() operations that can be performed on a semaphore guarantee atomic? Can a semaphore prevent two processes getting into the P()?
Suppose we have a binary semaphore, s, which has the value 1, and two processes simultaneously attempt to execute P on s. Only one of these operations will be able to complete before the next V operation on s; the other process attempting to perform a P operation is suspended. Taken from my university notes: We can t...
Semaphore
5,094,440
11
Is there any way to query the javascript synchronously from the main thread? Javascript is queried from the native code using an asynchronous function with a callback parameter to handle the response: func evaluateJavaScript(_ javaScriptString: String, completionHandler completionHandler: ((AnyObject!, NSError!) -> Voi...
If you must do this... As suggested in a comment to this answer you could run a tight loop around your semaphore wait like this. while (dispatch_semaphore_wait(sema, DISPATCH_TIME_NOW)) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalS...
Semaphore
28,388,197
11
Is it possible to query a semaphore created with sem_get without actually blocking like the sem_acquire function does? Cheers, Dan.
Unfortunately, PHP does not currently support non-blocking semaphores. If something like this is necessary you can utilize semaphores together with shared memory to create your own non-blocking lock mechanisms. Use a shared memory variable to mark whether or not a lock exists and then use a semaphore around operations ...
Semaphore
1,940,759
11
Going over this sample semaphore implementations (for SMP systems), I understand the test-and-set is required for multiprocessor atomic checks. However, once we add the atomic checks aren't the disable interrupts redundant ? The disable interrupts, anyway, only offer atomicity over one processor. Addition to the semaph...
While it is true that turning interrupts off on one processor is insufficient to guarantee atomic memory access in a multiprocessor system (because, as you mention, threads on other processors can still access shared resources), we turn interrupts off for part of the multiprocessor semaphore implementation because we d...
Semaphore
27,561,084
11
This is a follow-up to Can C++11 condition_variables be used to synchronize processes?. Can std::condition_variable objects be used as counting semaphores? Methinks not because the object seems bound to a std::mutex, which implies it can only be used as a binary semaphore. I've looked online, including here, here, and ...
Yes. struct counting_sem { counting_sem(std::ptrdiff_t init=0):count(init) {} // remove in C++17: counting_sem(counting_sem&& src) { auto l = src.lock(); // maybe drop, as src is supposed to be dead count = src.count; } counting_sem& operator=(counting_sem&& src) = delete; void take( std::size_t N=1...
Semaphore
40,335,671
11
A seemingly straightforward problem: I have a java.util.concurrent.Semaphore, and I want to acquire a permit using acquire(). The acquire() method is specified to throw InterruptedException if the thread is interrupted: If the current thread: has its interrupted status set on entry to this method; or is interrupt...
It is "spurious wakeup" not "spurious interrupt": "A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup." There is no InterruptedException thrown during a spurious wakeup. As you say in the comments: The thread wakes up but the interrupted flag is not set.
Semaphore
12,165,030
11
I am reading the book Java Concurrency in Practice. In a section about java.util.concurrent.Semaphore, the below lines are present in the book. It is a comment about its implementation of "virtual permit" objects The implementation has no actual permit objects, and Semaphore does not associate dispensed permits with...
Instead of "handing out" permit objects, the implementation just has a counter. When a new permit is "created" the counter is increased, when a permit is "returned" the counter is decreased. This makes for much better performance than creating actual objects all the time. The tradeoff is that the Semaphore itself canno...
Semaphore
7,554,839
11
I need to do some process synchronization in C. I want to use a monitor, and I have read a lot about them. However I have been unable to find out how to implement one in C. I have seen them done in Java and other languages like C++, but I am unable to find examples in C. I have looked through K&R and there is no examp...
I did this recently for a project, the concept I implemented was to have one thread start all of the others and then use semaphores and mutexes to control the inter process sync issues while dealing with shared memory. The concept of a monitor, in the context of the monitor design pattern, is a construct that is basica...
Semaphore
3,827,598
11
The documentation for the .NET Semaphore class states that: There is no guaranteed order, such as FIFO or LIFO, in which blocked threads enter the semaphore. In this case, if I want a guaranteed order (either FIFO or LIFO), what are my options? Is this something that just isn't easily possible? Would I have to write...
See this: The FifoSemaphore works exactly like a normal Semaphore but also guarantees that tokens are served out to acquirers in the order that they manage to acquire the internal lock. The usage of a FifoSemaphore is identical to a Semaphore.
Semaphore
2,553,982
11
A fairly basic question, but I don't see it asked anywhere. Let's say we have a global struct (in C) like so: struct foo { int written_frequently1; int read_only; int written_frequently2; }; It seems clear to me that if we have lots of threads reading and writing, we need a semaphore (or other lock) on the writt...
You need a mutex to guarantee that an operation is atomic. So in this particular case, you may not need a mutex at all. Specifically, if each thread writes to one element and the write is atomic and the new value is independent of the current value of any element (including itself), there is no problem. Example: each...
Semaphore
265,708
11
AFAIK, the mutex API was introduced to the kernel after LDD3 (Linux device drivers 3rd edition) was written so it's not described in the book. The book describes how to use the kernel's semaphore API for mutex functionality. It suggest to use down_interruptable() instead of down(): You do not, as a general rule, ...
Use mutex_lock_interruptible() function to allow your driver to be interrupted by any signal. This implies that your system call should be written so that it can be restarted. (Also see ERESTARTSYS.) Use mutex_lock_killable() to allow your driver to be interrupted only by signals that actually kill the process, i.e., w...
Semaphore
18,298,962
10
I have multiple threads accessing an external resource – a broswer. But only one thread can access it at a time. So, I am using a semaphore to synchronise them. However, one thread, which takes input from the GUI and then access the browser for the results, should have priority over other threads and I am not sure how ...
There're no synchronization primitives in Java that would allow you to prioritise one thread over others in the manner you want. But you could use another approach to solving your problem. Instead of synchronizing threads, make them produce small tasks (for instance, Runnable objects) and put those tasks into a Priorit...
Semaphore
39,437,411
10
How should I structure the try/finally when using a SemaphorSlim with cancellation token so that OperationCancelledException is handled correctly? In Option A, cancelling the token source throws OperationCancelledException but does not call Release(). In Option B, cancelling the token source throws OperationCancelled...
Option A is more correct here. You do not need to Release the SemaphoreSlim when you cancel, as you never actually acquire and increment its count. As such, you don't want to release unless your Wait call actually succeeded. From this MSDN Page on using Semaphore and SemaphoreSlim: It is the programmer's responsibil...
Semaphore
6,233,774
10
When dealing with threads (specifically in C++) using mutex locks and semaphores is there a simple rule of thumb to avoid Dead Locks and have nice clean Synchronization?
A good simple rule of thumb is to always obtain your locks in a consistent predictable order from everywhere in your application. For example, if your resources have names, always lock them in alphabetical order. If they have numeric ids, always lock from lowest to highest. The exact order or criteria is arbitrary. The...
Semaphore
1,892,619
10
Why am I deadlocking? - (void)foo { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ [self foo]; }); // whatever... } I expect foo to be executed twice on first call.
Neither of the existing answers are quite accurate (one is dead wrong, the other is a bit misleading and misses some critical details). First, let's go right to the source: void dispatch_once_f(dispatch_once_t *val, void *ctxt, dispatch_function_t func) { struct _dispatch_once_waiter_s * volatile *vval = ...
Semaphore
19,176,219
10
I have threads which are given random number (1 to n) and are instructed to print them in sorted order. I used semaphore such that I acquire the number of permits = random number and release one permit more than what was acquired. acquired = random number; released = 1+random number Initial permit count for semaphore...
It's a clever strategy, but you're misunderstanding how Sempahore hands out permits. If you run your code enough times you'll actually see it reach step two: Acquiring lock -- 5 Acquiring lock -- 1 1 Releasing lock -- 1 Acquiring lock -- 3 Acquiring lock -- 2 2 Acquiring lock -- 4 Releasing lock -- 2 If you keep on re...
Semaphore
36,992,758
10
I am currently optimizing an existing, very slow and timing out production application. There is no option to re-write it. In short, it is a WCF service that currently calls 4 other "worker" WCF services sequentially. None of the worker services are dependent on results from the other. So we would like it to call them...
You didn't explain how you wanted to limit the concurrent calls. Do you want 30 concurrent worker tasks running, or do you want 30 WCF calls, each of which have all their worker tasks running concurrently, or do you want concurrent WCF calls to each have their own limit of concurrent worker tasks? Given you said that e...
Semaphore
57,572,902
10
class myclass { private Semaphore _sync; myclass () { _sync = new Semaphore(1,1); } doasync() { _sync.WaitOne(); //do some stuff _sync.Release(); } } somefunctionsomewhere() { var myobject = new myclass(); //spawn 100 threads t...
Short answer: No, you don't need to call Dispose(). Long answer: Though it is recommended to call Dispose() when you are finished using the Semaphore, the garbage collector will take care of the semaphore's resources sooner or later. An explicit call to Dispose() will guarantee an early release of the associated resou...
Semaphore
13,452,978
10
Does using a lock have better performance than using a local (single application) semaphore? I read this blog from msdn : Producer consumer solution on msdn and I didn't like their solution to the problem because there are always 20 elements left in the queue. So instead, I thought about using a 'Semaphore' that will b...
Lock(obj) is the same as Monitor.Enter(obj); A lock is basicaly an unary semaphore. If you have a number of instances of the same ressource (N) you use a semaphore with the initialization value N. A lock is mainly used to ensure that a code section is not executed by two threads at the same time. So a lock can be imple...
Semaphore
3,489,382
10
I am trying to limit the number of simultaneous async functions running using a semaphore, but I cannot get it to work. My code boils down to this: import asyncio async def send(i): print(f"starting {i}") await asyncio.sleep(4) print(f"ending {i}") async def helper(): async with asyncio.Semaphore(v...
Please find the working example below, feel free to ask questions: import asyncio async def send(i: int, semaphore: asyncio.Semaphore): # to demonstrate that all tasks start nearly together print(f"Hello: {i}") # only two tasks can run code inside the block below simultaneously async with semaphore: ...
Semaphore
66,724,841
10
I have a fairly complex WPF application that (much like VS2013) has IDocuments and ITools docked within the main shell of the application. One of these Tools needs to be shutdown safely when the main Window is closed to avoid getting into a "bad" state. So I use Caliburn Micro's public override void CanClose(Action<boo...
I don't think you have much choice than to block the return. However your updates should still run despite the UI thread being locked. I wouldn't use a ManualResetEventSlim, but just a simple wait() and a single task without a continuation. The reason for that is by default Task.Run prevents the child task (your contin...
Semaphore
32,167,520
10
Let's say I create a semaphore. If I fork a bunch of child processes, will they all still use that same semaphore? Also, suppose I create a struct with semaphores inside and forked. Do all the child processes still use that same semaphore? If not, would storing that struct+semaphores in shared memory allow the child...
Let's say I create a semaphore. If I fork a bunch of child processes, will they all still use that same semaphore? If you are using a SysV IPC semaphore (semctl), then yes. If you are using POSIX semaphores (sem_init), then yes, but only if you pass a true value for the pshared argument on creation and place it in sh...
Semaphore
6,847,973
10
This past semester I was taking an OS practicum in C, in which the first project involved making a threads package, then writing a multiple producer-consumer program to demonstrate the functionality. However, after getting grading feedback, I lost points for "The usage of semaphores is subtly wrong" and "The program as...
Your semaphores do nothing to protect buffer, head, etc in the innermost loop. One thread acquires sempahore "empty", the other acquires semaphore "full" while no other semaphores are held. This seems to guarantee eventual corruption.
Semaphore
4,514,778
10
I've created a service, and the module for it looks like this: launchdarkly.module.ts @Module({ providers: [LaunchdarklyService], exports: [LaunchdarklyService], imports: [ConfigService], }) export class LaunchdarklyModule {} (this service/module is to let the application use LaunchDarkly feature-flagging) I'm h...
Assuming the LaunchdarklyService needs the ConfigService and that is injected into the constructor, you can provide a mock variation of the ConfigService by using a Custom Provider to give back the custom credentials you need. For example, a mock for your test could look like describe('LaunchdarklyService', () => { l...
LaunchDarkly
65,636,980
23
gitlab-ci-multi-runner register gave me couldn't execute POST against https://xxxx/ci/api/v1/runners/register.json: Post https://xxxx/ci/api/v1/runners/register.json: x509: cannot validate certificate for xxxx because it doesn't contain any IP SANs Is there a way to disable certification validation? I'm using Gitlab...
Based on Wassim's answer, and gitlab documentation about tls-self-signed and custom CA-signed certificates, here's to save some time if you're not the admin of the gitlab server but just of the server with the runners (and if the runner is run as root): SERVER=gitlab.example.com PORT=443 CERTIFICATE=/etc/gitlab-runner/...
GitLab
44,458,410
45
I've created project and repo on my gitlab.com account, generated private key, now I'm trying to do API call to get list of commits. Now I want to get list of projects via API, from documentation https://docs.gitlab.com/ce/api/projects.html#list-projects GET /projects So I'm doing: curl --header "PRIVATE-TOKEN: XXXXXX...
The correct base url for the hosted GitLab is https://gitlab.com/api/v4/ so your request to GET /projects would be curl --header "PRIVATE-TOKEN: XXXXXX" "https://gitlab.com/api/v4/projects" That would return all projects that are visible to you, including other user's public projects. If you wish to view just your pro...
GitLab
39,751,840
45
I have a problem with my releases in GitLab. I created them in my project with tags. Now I want to remove them, so I deleted the associated tags but my releases are always displayed. I searched on Google and Stack Overflow but I can't find any solutions. How can I remove these releases without their tags?
Go to Project Overview -> Releases Click the release you want to delete Scroll to the bottom. Find the tag icon. Click on the tag. There is a trash can button for the tag. Deleting the tag will delete the release as well.
GitLab
54,418,978
44
I'm trying to delete a branch both locally and in a remote GitLab repository. Its name is origin/feat. I tried git push --delete origin feat. Git complains: remote: error: By default, deleting the current branch is denied, because the next remote: 'git clone' won't result in any file checked out, causing confusion. rem...
Try git push origin --delete <branch-name>
GitLab
44,657,989
44
I'm not able run the gitlab pipeline due to this error Invalid CI config YAML file jobs:run tests:artifacts:reports config contains unknown keys: cobertura
Check the latest correct doc here: https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscoverage_report Some of the docs are in somewhat of a messy state right now, due to the new release as mentioned. This was the fix for me: artifacts: expire_in: 2 days reports: coverage_report: ...
GitLab
72,138,080
43
I have a gitlab CI build process with 4 steps, in which artifacts produced in first step are packaged into docker image in 2nd step, then the output image is given as the artifact to 3rd step, and there is a 4th step afterwards, that notifies external service. The 2nd step needs artifacts from step 1, the 3rd step need...
As per the gitlab-ci documentation: To disable artifact passing, define the job with empty dependencies: job: stage: build script: make build dependencies: [] I've found the same issue here: https://gitlab.com/gitlab-org/gitlab-runner/issues/228 This seems to be fixed in: https://gitlab.com/gitlab-org/gitlab-c...
GitLab
47,657,634
43
I am trying to get GitLab working on my server (running CentOS 6.5). I followed the gitlab-receipe to the line, but I just can't get it working. I am able to access the web interface, create new projects but pushing to the master branch returns the following error : fatal: protocol error: bad line length character: Th...
If anyone else has this problem, the solution is to change the login shell of the user 'git' (or whatever your user is called) to /bin/bash. This can be done via the command : usermod -s /bin/bash git (Link). The reason for changing the login shell is because the default shell for the git user is /sbin/nologin (or simi...
GitLab
22,314,298
43
I have tried searching for it everywhere, but I can’t find anything. It would be really awesome if someone could define it straight out of the box. I don’t know what an instance of GitLab URL is. I’m asking if someone could clarify what it is, and where can I get it. I am currently trying to add it in Visual Studio Cod...
The instance URL of any GitLab install is basically the link to the GitLab you're trying to connect to. For example, if your project is hosted on gitlab.example.com/yourname/yourproject then for the instance URL enter https://gitlab.example.com. Another example, if your project is hosted on gitlab.com/username/project ...
GitLab
58,236,175
42
I am trying to set an environment variable for my GitLab Runner based on the branch that the commit originated from. I have 4 kubernetes clusters: staging, integration, production, and qa. Essentially I want to deploy my application to the proper cluster based on the branch I am pushing to. image: google/cloud-sdk:late...
The comment above helped me figure it out. So I use a VERSION file that right now contains 0.0.0 which I manipulate to create other variables # determine what branch I am on - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then ENVIRONMENT="qa"; else ENVIRONMENT="$CI_COMMIT_REF_NAME"; fi # determine patch number for s...
GitLab
53,965,695
42
Is it possible to invalidate or clear a pipeline cache with the Gitlab CI after a pipeline completes? My .gitlab-ci.yml file has the following global cache definition cache: key: "%CI_PIPELINE_ID%" paths: - './msvc/Project1`/bin/Debug' - './msvc/Project2`/bin/Debug' - './msvc/Project3`/bin/Debug' The c...
Artifacts are the solution as mentioned in the comments. However there is an option to clear caches in the Pipelines page as shown in the image below.
GitLab
48,469,675
42
I have a Dockerfile that starts with installing the texlive-full package, which is huge and takes a long time. If I docker build it locally, the intermedate image created after installation is cached, and subsequent builds are fast. However, if I push to my own GitLab install and the GitLab-CI build runner starts, this...
I suppose there's no simple answer to your question. Before adding some details, I strongly suggest to read this blog article from the maintainer of DinD, which was originally named "do not use Docker in Docker for CI". What you might try is declaring /var/lib/docker as a volume for your GitLab runner. But be warned, d...
GitLab
35,556,649
42
There are 3 stages - build, test and deploy in .gitlab-ci.yml. A nightly regression test stage needs to be run nightly. Here's the relevant .gitlab-ci.yml code: stages: - build - test - deploy build_project: stage: build script: - cd ./some-dir - build-script.sh except: - tags #Run this only whe...
except and only can specify variables that will trigger them. You can use the following in your .gitlab-ci.yml: build1: stage: build script: - echo "Only when NIGHTLY_TEST is false" except: variables: - $NIGHTLY_TEST test1: stage: test script: - echo "Only when NIGHTLY_TEST is true" ...
GitLab
39,988,497
41
I'd can't seem to find any documentation of manual staging in Gitlab CI in version 8.9. How do I do a manual stage such as "Deploy to Test"? I'd like Gitlab CI to deploy a successful RPM to dev, and then once I've reviewed it, push to Test, and from there generate a release. Is this possible with Gitlab CI currently?
You can set tasks to be manual by using when: manual in the job (documentation). So for example, if you want to want the deployment to happen at every push but give the option to manually tear down the infrastructure, this is how you would do it: stages: - deploy - destroy deploy: stage: deploy script: - [...
GitLab
31,904,686
41
I have a GitLab installation running, and I have a repository that I want to share with my friends. I can't understand the flow of sending pull requests in GitLab. A user can't fork my repository or access my project (unless he is my on team). A merge request can be from one branch to another in my repository. How do p...
GitLab.com co-founder here. Forking should work fine in recent versions of GitLab (6.x). You can fork a repo belonging to someone else and then create a merge request (the properly named version of the GitHub pull request).
GitLab
15,396,753
41
According to the documentation, it should be possible to access GitLab repos with project access tokens: The username is set to project_{project_id}_bot, such as project_123_bot. Never mind that that's a lie -- the actual user is called project_4194_bot1 in my case; apparently they increment a number for subsequent t...
It seems that using the project name as username works. In your case replacing project_4194_bot1 with my-project should work: git clone "https://my-project:$PROJECT_TOKEN@my.gitlab.host/my-group/my-project.git" EDIT: One can actually use any non-blank value as a username (see docs), as others correctly pointed out.
GitLab
63,924,723
40
So, in addition to GitKraken won't let me clone from a private repo on GitHub I get this screen when opening my GitLab Repo: Anyone got a solution of how to make my Repo 'non-private' or how to make GitKraken let me open this without the Pro Plan? Already tried: Generating new SSH Key in GitKraken Removing Repo, Gene...
6.5.1 is the last version to support private repo. You can see the release details at this link https://blog.axosoft.com/gitkraken-v6-0/#pricing-changes OR https://support.gitkraken.com/release-notes/6x/ And you can also download it (Mac version) from Axosoft https://release.axocdn.com/darwin/GitKraken-v6.5.1.zip OR ht...
GitLab
58,095,592
40
recently my runners have been stopped and I don't know why? I've just upgraded nodejs on the server and it did happen. after this problem, I've tried to update gitlab to the latest version and check the runner status but the problem still persists and in the title of grey icon shows: Runner is offline, the last conta...
To me, the following solved the problem: gitlab-runner restart Where gitlab-runner is a symlink to gitlab-ci-multi-runner: GitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab. It is used in conjunction with GitLab CI, the open-source continuous integration servic...
GitLab
44,746,357
40
Dear stackoverflow community, once more I turn to you :) I've recently come across the wonder of Gitlab and their very nice bundled CI/CD solution. It works gallantly however, we all need to sign our binaries don't we and I've found no way to upload a key as I would to a Jenkins server for doing this. So, how can I, wi...
Usually I store keystore file (as base64 string), alias and passwords to Gitlab's secrets variables. In the .gitlab-ci.yml do something like: create_property_files: stage: prepare only: - master script: - echo $KEYSTORE | base64 -d > my.keystore - echo "keystorePath=my.keystore" > signing.properties ...
GitLab
51,725,339
39
Look at this picture showing gitlab ce memory consumption. I really dont need all of those workers, sidekiq or unicorn or all of those daemon. This is on IDLE. I mean, I installed this to manage 1 project, with like 4 people, I dont need all those daemon. Is there any way to reduce this ?
I also had problems with gitlab's high memory consumption. So I ran the linux tool htop. In my case I found out that the postgresl service used most of the memory. With postgres service running 14.5G of 16G were used I stopped one gitlab service after the other and found out that when I stop postgres a lot of memory wa...
GitLab
36,122,421
39
When having one gitlab runner serving multiple projects, it can only run one CI pipeline while the other project pipelines have to queue. Is it possible to make a gitlab runner run pipelines from all projects in parallel? I don't seem to find anywhere a configuration explanation for this.
I believe the configuration options you are looking for is concurrent and limit, which you'd change in the GitLab Runners config.toml file. From the documentation: concurrent: limits how many jobs globally can be run concurrently. The most upper limit of jobs using all defined runners. 0 does not mean unlimited limit...
GitLab
51,828,805
38
I will like to clone my android code from gitlab repository in Android Studio 0.8.1.I checked into VCS >> Checked out from Version Control >> Git >> Added HTTP url here.It prompts me that "Repositroy test has failed".Kindly help me to sort out the issue.I have checked the plugins as well.Thanks a lot.
You need to download and install git from http://git-scm.com/downloads Then you need to track the git.exe on AndroidStudio: Go to Settings > Project Settings > Version Control > VCSs > Git > Path to Git executable Select (or type) executable path, eg: D:\Program Files (x86)\Git\cmd\git.exe If you installed GitHub Des...
GitLab
24,625,335
38
My Gitlab (version 5) is not sending any e-mails and I am lost trying to figure out what is happening. The logs give no useful information. I configured it to used sendmail. I wrote a small script that sends e-mail through ActionMailer (I guess it is what gitlab uses to send e-mail, right?). And it sends the e-mail cor...
Stumbled upon this issue today, here's my research: Debugging SMTP connections in the GitLab GUI is not supported yet. However there is a pending feature request and a command line solution. Set the desired SMTP settings /etc/gitlab/gitlab.rb and run gitlab-ctl reconfigure (see https://docs.gitlab.com/omnibus/settings/...
GitLab
16,125,623
38
I'm using Hosted Gitlab to host my Git repositories, and more recently I've been using it to build/deploy PHP and Java applications to servers. What I'd like to do is once a build is complete, deploy the application using SSH. Sometimes this might just be uploading the contents of the final build (PHP files) to a serve...
You can store your SSH key as a secret variable within gitlab-ci.yaml and use it during your build to execute SSH commands, for more details please see our documentation here. Once you have SSH access you can then use commands such as rsync and scp to copy files onto your server. I found an example of this in another ...
GitLab
42,676,369
37
Here is what my dashboard looks like: Not really sure where to add an SSH key. Anyone have any idea?
Go to your GitLab account: https://gitlab.com/ Click on Settings on the top right drop-down, which will appear once you select the icon(white-fox image [specific to my profile]). Click on Settings on the top right drop-down, which will appear once you select the icon(white-fox image). Click on SSH Keys: Add/Paste t...
GitLab
35,901,982
37
I'm running GitLab in a container of Docker but it's okay so far, no problem with that at all. I'm just in doubt about the creation of repositories in projects. I've created my first project in GitLab then after it creation i'd been redirected to a page with some commands to use in terminal. There were three sections, ...
I only have time to give a short answer right now, but I hope it helps: In short: NO But also: YES, after a fashion There is a one-to-one correspondence between repositories and projects (which would perhaps better be called repositories as well). One Solution: Gitlab supports the creation of groups of projects/repo...
GitLab
28,416,576
37
I would like to create a webhook within Gitlab to automatically update a mirror repository on Github, whenever a push event happens. I've checked this page, but I didn't understand how it is done. My Gitlab version is 6.5. Here is the configuration page: What should I put in URL? Where do I need to place the script to...
You don't need a webhook for that. A regular post-receive hook will work very well. To create and use such a hook you just have to login on the server where your gitlab is installed and create an ssh key for git user. sudo -u git ssh-keygen -f /home/git/.ssh/reponame_key (do not type any passphrase when prompted) Go t...
GitLab
21,962,872
37
I've been using Git for the past few months. Recently when I try to clone or to push, I keep on getting this error. I've researched on the internet but so far no solution has worked for me. Does anyone have an idea? External note : Now I moved to different country, it was working perfectly where I was before. Git Versi...
This is solution fix this issue on ubuntu server 14.04.x 1, Edit file: sudo nano /etc/apt/sources.list 2, Add to file sources.list deb http://security.ubuntu.com/ubuntu xenial-security main deb http://cz.archive.ubuntu.com/ubuntu xenial main universe 3, Run command update and update CURL to new version apt-get updat...
GitLab
60,262,230
36
I started to look in to ssl certificates when I stumbled upon let's encrypt, and I wanted to use it with gitlab, however being that it is running on a raspberry pi 2 and its running quite perfectly now (so I dont want to mess anything up), he would I go about installing a lets encrypt ssl certificate properly? PS: My i...
The by far best solution I was able to find for now is described in this blog post. I won't recite everything, but the key points are: Use the webroot authenticator for Let's Encrypt Create the folder /var/www/letsencrypt and use this directory as webroot-path for Let's Encrypt Change the following config values in /e...
GitLab
34,189,199
36
My institution recently installed GitLab for us. I've figured out how to install R packages from the GitLab server using devtools::install_git and it works as long as the project is public. #* When modeltable project has Public status devtools::install_git('https://mini-me2.lerner.ccf.org/nutterb/modeltable.git') How...
I'd highly recommend going the SSH route, and the below works for that. I found making the leap to SSH was easy, especially with R and RStudio. I'm using Windows in the below example. Edits from code I use in practice are in all caps. creds = git2r::cred_ssh_key("C:\\Users\\MYSELF\\.ssh\\id_rsa.pub", ...
GitLab
27,319,207
36
I've signed up to Gitlab using the connection they have with Google Accounts. Once that is made and I have permission to clone from a git repository, I try to clone using the https:// link (not the git: SSH one) Now to complete this process, I am asked my username and password, but what is that in this scenario? Please...
You can actually use the https link if you login using a Google, Twitter or GitHub link but you have to have an actual GitLab password. If you've already created your account by logging in with a social network, all you have to do is use the Forgot Password feature. log out and then use the "Forgot your password?" bu...
GitLab
22,436,827
36
GitLab offers the project access levels: "Guest" "Reporter" "Developer" "Master" for "team members" co-operating with a specific project. "Master" and "Guest" are self-explanatory, but the others aren't quite clear to me, in their extents as well as in their granularity. What is the difference between these levels?
2013: The project_security_spec.rb test each profile capabilities, which are listed in ability.rb: (2017 GitLab 10.x: this would be more likely in app/policies/project_policy.rb) See also, as noted in jdhao's answer: "Project members permissions" Those rules are quite explicit: def public_project_rules [ :downloa...
GitLab
17,657,781
36
I would like to add my gitlab account to sourcetree. Inside Preferences -> Accounts, I tried the 'add' button host: GitLab.com Auth type: greyed out username xxxxxx password: xxxxxx protocol: https when I go to save. I get a pop up screen that says: "We couldn't connect to GitLab with your (XXXXXX) credentials. Chec...
Someone on the GitLab forum had a similar issue recently, and they documented the steps to solve it: I eventually noticed that for github and bitbucket the credentials are through "Oauth", and for GitLab "Personal access token". I had generated yesterday a toke, but hadn't used anywhere. Steps to add a repo from GitL...
GitLab
53,184,950
35
I have several developers working on a local Gitlab instance. The client requires that their Github repo is kept updated. So our Gitlab repo should push any commits directly to Github. Any commits to Github should likewise be pulled into Gitlab. I could do the first part (dev --> gitlab --> github) with jenkins or so...
It's only in the enterprise edition and on GitLab.com, but GitLab has introduced this feature directly, without any workarounds. They've documented pulling/pushing from/to a remote repository in GitLab Docs → User Docs → Projects → Repositories → Mirroring. It's in the same section of configuration that you can push, t...
GitLab
32,762,024
35
Project cannot be transferred, because tags are present in its container registry I am encountering the above error when I try to transfer my git repository to a group. I have checked in Repository/Tags but there are none. I have also checked in CI/CD tabs and there's nothing outstanding there either. So I'm wonderin...
Issue 33301 mentions: the only way to move a project with containers in the registry is to first delete them all. Meaning delete the container tags in the registry (not the repository or CI/CD) Navigate to sidebar menu Package->Container Registry on a project where Container registry is enabled Click on the button "...
GitLab
61,557,101
34
i want to run a script that is needed for my test_integration and build stage. Is there a way to specify this in the before script so i don't have to write it out twice. before_script: stage: ['test_integration', 'build'] this does not seem to work i get the following error in gitlab ci linter. Status: syntax is in...
The before_script syntax does not support a stages section. You could use before_script as you have done without the stages section, however the before_script stage would run for every single job in the pipeline. Instead, what you could do is use YAML's anchor's feature (supported by Gitlab), which allows you to duplic...
GitLab
54,074,433
34
On a private repository from gitlab, when I run git clone git@git.privateserver.local:group/project-submodule.git the clone completes successfully. As part of the cloning process, I'm asked for the passphrase of my private key. When I run submodule update --init "group/project-submodule" It fails with: Permission de...
Git tries to clone the submodule using ssh and not https. If you haven't configured your ssh key this will fail. You can setup ssh-agent to cache the password for the ssh key and get git to use that. Or change to https. Git is a bit confusing regarding submodules. They are configured in the .gitmodules file in the dire...
GitLab
49,191,565
34
I'm currently using gitlab.com (not local installation) with their multi-runner for CI integration. This works great on one of my projects but fails for another. I'm using 2012R2 for my host with MSBuild version 14.0.23107.0. I know the error below shows 403 which is an access denied message. My problem is finding t...
To resolve this issue I had to add myself as a project member. This is a private repo. I'm not sure if that caused the runner to fail with the different permission setup or not, but it is highly possible. This help article at gitlab outlines this issue. With the new permission model in place, there may be times th...
GitLab
40,006,690
34
I have lost my Phone and do not have the recovery code for my 2FA for GitLab. So I am locked out of my account. What are my options?
I know this is an old question, but the following, which I have tested only with gitlab.com free hosted accounts, may be useful for others with GitLab 2fa problems. IF you have set up 2fa but then lost access to your 2fa device for some reason, and you have lost (or never saved) your recovery codes, and you had previo...
GitLab
39,142,153
34
Is it possible to mark gitlab ci jobs to start manually? I need it for deploying application but I want to decide if it's going to be deployed
This has changed since the first answer has been posted. Here's the link to the original Gitlab Issue. It is now supported to do something like production: stage: deploy script: run-deployment $OMNIBUS_GITLAB_PACKAGE environment: production when: manual Note the when: manual attribute. The UI updates itself to...
GitLab
36,663,765
34
I see two possibilities of doing this: Do a replace of the local branch with the changes from remote master Follow the work flow that I get using Gitlab by creating a merge request and merge the changes from master branch into the branch that I wish to update to the latest from master What are the advantages and disa...
The simple answer - there are plenty of more complicated ones - is to just do a merge, so: git checkout master git pull git checkout <your-branch> git merge master (This is effectively the same as you describe in option 2) Depending on your settings, you might not need all of those steps (but doing them all won't hurt...
GitLab
34,656,523
34
There is a Git branch which was deleted by GitLab when closing a merge request. I would like to restore (undelete) that branch; however, I'm not seeing an option in the UI to do so. In GitHub it is possible to restore a branch deleted by a pull request after the fact (via the "Restore branch" button on the pull reques...
Restoring a deleted branch is an open issue, so GitLab has not implemented this feature at the time of this writing. However, if you know the commit ID (and it hasn't been pruned), you can create a new branch from that commit: From the Web UI, go to Repository > Commits Find the commit you want and copy the SHA to you...
GitLab
69,761,824
33
When a non-owner dev pushes a branch to our Gitlab repo, it returns a "pipeline failed" message, with the detail "Pipeline failed due to the user not being verified". On the dev's account, he's getting a prompt to add a credit card to verify him to be eligible for free pipeline minutes. But I haven't set up any pipelin...
In my case, I was using my own runner for my project. In that case also, I got this error. I fixed the error by disabling the shared runner in my project. Under Setting -> CICD -> Runner (Expand) -> Under the shared runner section, disable Shared runner.
GitLab
67,875,196
33
My GitLab pipelines execute automatically on every push, I want to manually run pipeline and not on every push. Pipeline docs: https://docs.gitlab.com/ee/ci/yaml/#workflowrules I tried this in .gitlab-ci.yml workflow: rules: - when: manual # Error: workflow:rules:rule when unknown value: manual
You should specify a condition that tells Gitlab to not run the pipeline specifically on push events like so: workflow: rules: - if: '$CI_PIPELINE_SOURCE == "push"' when: never # Prevent pipeline run for push event - when: always # Run pipeline for all other cases
GitLab
64,557,223
33
I currently set up a Jenkins Multibranch Pipeline job that is based on a Git repository hosted on our GitLab server. Jenkins can read the branches in the repository and creates a job for every branch in the repository. But I can't figure out how to trigger the jobs with webhooks in GitLab. My questions are: How can I ...
You need to install the GitLab Plugin on Jenkins. This will add a /project endpoint on Jenkins. (See it in Jenkins => Manage Jenkins => Configure System => GitLab) Now add a webhook to your GitLab project => Settings => Integrations. (or in older GitLab versions: GitLab project => Wheel icon => Integrations, it seems y...
GitLab
40,979,405
33
I am trying to connect my GitLab repository with IntelliJ-IDEA, and it still cant connect to the repo. I have tried the next things: I have msysgit installed correctly Generated the SSH keys (https://help.github.com/articles/generating-ssh-keys/) Added the key on GitLab keys Define the enviroment variables HOME USERPR...
Try to install plugin: Settings -> Plugins -> Browse repositories -> type GitLab Projects Plugin minimum version 1.3.0 and go to Settings -> Other Settings -> GitLab Settings Fill GitLab Server Url with https://gitlab.com/ (ensure slash at the end) and GitLab API Key with string (private token which is shown as the ...
GitLab
31,975,143
33