Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
travis-deploy-once
Advanced tools
Run a deployment script only once in the Travis test matrix.
This library is deprecated and will not be maintained. We recommend to use Build Stages instead. It’s a clearer and more flexible way to orchestrate jobs within a build.
For Travis builds running multiple jobs (to test with multiple Node versions and/or OSs), travis-deploy-once
run some code only once, after all other jobs have completed successfully.
travis-deploy-once
is usually used in the after_success
step. But if you want your build to break in case the travis-deploy-once
script returns an error, you can set it in the script
or before_script
step (see Travis Build Lifecycle).
Your code will run only on the job identified as the build leader, which is determined as follow, by order of priority:
BUILD_LEADER_ID
environment variable.node_js: node
).node_js: lts/*
).Note: If multiple jobs match, the one with the highest job ID (which corresponds to the last one defined in .travis.yml
) will be identified as the build leader.
Usage: travis-deploy-once.js [script]
Run the script
passed in the first argument only if the current job is the build leader and all other jobs are successful and return with the exit code of the script. Return with exit code 0
otherwise.
In .travis.yml
:
language: node_js
node_js:
- 8
- 6
- 4
os:
- osx
- linux
after_success:
- npm install -g travis-deploy-once
- travis-deploy-once "deploy-script --script-arg script-arg-value"
The script deploy-script
will be called only for the node 8 job running on linux
. It will be passed the arguments --script-arg script-arg-value
.
Return with exit code 0
if the current job is the build leader and all other jobs are successful. Return with exit code 1
otherwise.
In .travis.yml
:
language: node_js
node_js:
- 8
- 6
- 4
os:
- osx
- linux
after_success:
- npm install -g travis-deploy-once
- travis-deploy-once && deploy-script --script-arg script-arg-value
The script deploy-script
will be called only for the node 8 job running on linux
. It will be passed the arguments --script-arg script-arg-value
.
Type: String
Default: GH_TOKEN
or GITHUB_TOKEN
environment variable
GitHub OAuth token.
Type: Number
Default: BUILD_LEADER_ID
environment variable
Define which Travis job will run the script (build leader). If not defined the build leader will be the Travis job running on the highest Node version.
Type: Boolean
Default: false
true
to use Travis Pro, false
to use Travis for Open Source.
Type: String
Default: TRAVIS_URL
environment variable
Travis Enterprise URL. If defined, the -p, --pro option will be ignored.
Note: This is the URL of the API endpoint, for example https://travis.example.com/api
.
Type: Boolean
Show help.
Type: Boolean
Show version number.
npm install --save travis-deploy-once
In the module my-module
:
const deployOnce = require('travis-deploy-once');
try {
const result = await deployOnce({travisOpts: {pro: true}, githubToken: 'xxxxxx', buildLeaderId: 1});
if (result === true) deployMyThing();
if (result === false) console.log('Some job(s) failed');
if (result === null) console.log('Did not run as the build leader');
} catch (err) {
// something went wrong, and err will tell you what
}
In .travis.yml
:
language: node_js
node_js:
- 8
- 6
- 4
os:
- osx
- linux
after_success:
- npm run my-module
The script my-module
with be called for each node version on both OSs and deployMyThing
will be called only for the node 8 job running on linux
.
deployOnce([options])
Returns a Promise
that resolves to:
true
if the current Travis job is the build leader, the current script
phase is successful and all other job have completed successfully. => Your code can safely run.false
if at least one Travis job failed. => Your code should not run.null
if the current Travis job is not the build leader. => Your code should not run, and will be executed on the build leader.Throws an Error
if:
Type: Object
Type: String
Default: process.env.GH_TOKEN
or process.env.GITHUB_TOKEN
GitHub OAuth token.
Type: Number
Default: process.env.BUILD_LEADER_ID
Define which Travis job will run the script (build leader). If not defined the build leader will be the Travis job running on the highest Node version.
Type: Object
Type: Boolean
Default: false
true
to use Travis Pro, false
to use Travis for Open Source.
Type: String
Default: process.env.TRAVIS_URL
Travis Enterprise URL. If defined, the pro option will be ignored.
Note: This is the URL of the API endpoint, for example https://travis.example.com/api
.
FAQs
Run a deployment script only once in the Travis test matrix
We found that travis-deploy-once demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.