Support for Semaphore CI 2
foxdb opened this issue Β· comments
Support Semaphore CI 2
Documentation:
- (current) Semaphore CI environment: https://semaphoreci.com/docs/available-environment-variables.html
- (new) Semaphore CI 2 environment:https://docs.semaphoreci.com/article/12-environment-variables
Environment variables:
- service detection:
SEMAPHORE=true
is still there. In order to tell the difference between Semaphore CI 1 and Semaphore CI 2, a second environment variable could be used. For example:BRANCH_NAME
exists only in v1, andSEMAPHORE_GIT_BRANCH
exists only in v2. - Branch:
SEMAPHORE_GIT_BRANCH
- Commit sha:
SEMAPHORE_GIT_SHA
- Is Pull request: not sure!
- Pull request: not sure!
- Build number: good question. I would tend to say
SEMAPHORE_WORKFLOW_ID
, but it there is alsoSEMAPHORE_PIPELINE_ID
.
From the Semaphore docs:
The SEMAPHORE_PIPELINE_ID environment variable remains the same throughout all the blocks of a pipeline
The SEMAPHORE_WORKFLOW_ID environment variable remains the same during a pipeline run and is available in all the blocks of a pipeline as well as in all promoted and auto promoted pipelines.
Possible implementation
Below is a suggestion of implementation. Happy to discuss it, and happy to work on the issue if that's fine!
semaphore-2.test.js
semaphore-2.js
- adapt
index.test.js
to test that semaphore 2 environments should not be positives for semaphore 1 environments, and also the reverse. - adapt
semaphore.js
to not be positives for semaphore 2 environments
I would prefer to do something like services/circleci.js where we handle both v1 and v2 in the same file.
Understood, sounds good! I will take a look and make a PR!
I recently switched over from using, what is now apparently known as, Semaphore Classic to using Semaphore CI 2.0 and got hit by the fact that this project doesn't support 2.0 yet, which is understandable. I've got my builds passing again by adding a few commands to fill the old expected environment variables with the values from the new environment variables, but it would be great if I could rip that band-aid off.
As this PR hasn't progressed since February would anyone mind if I took a crack at it? If I'm stepping on anyones toes let me know and I'll wait until the original is merged and then remove what are essentially my hacks.
Thanks for this project and the original PR π
Hi @Jmclerck
I ended up fixing my pipeline like you did (got my builds passing again by adding a few commands to fill the old expected environment variables
) and got lazy on addressing the feedback on this PR review. I actually forgot about it, sorry!
Awesome if you plan to give it a crack! Could you tag me on your PR so I can close this one? Thanks!
π This issue has been resolved in version 4.5.0 π
The release is available on:
Your semantic-release bot π¦π