how to start ci on master tag and dev push on Drone 1.0-rcX,
I can do this at version 0.8 , but now I can’t at version 1.0
Does that solve your problem ?
Also keep in mind that 0.8
yaml syntax is compatible with 1.0
. (Unless that changed recently ?)
0.8 Pipeline Conditions is only has branches conditions, don’t have event so it can’t solve the tag event
The link is not useful, I just want two happening:
- tag event
- dev branch push event
I found it is so diffcult to restrict, maybe I should change a way
maybe I can use the two pipeline to do that
In 1.0 version , how to pre define some tpl like this
# if i write this at 1.0 version, there will have a wrong
xcache: &cache
image: drillster/drone-volume-cache
mount: [ './node_modules', '/drone/docker' ]
volumes: [ '/tmp/cache:/cache' ]
pipeline:
restore-cache:
<<: *cache
restore: true
if i success, I will share that
I realized it by use two pipelines , but it has too many repeat code , not beautiful, so I hidde the code in my project
Use jsonnet there is less code.
local Cache(name, settings) = {
name: name,
image: 'drillster/drone-volume-cache',
settings: settings,
volumes: [
{ name: 'cache', path: '/cache' }
]
};
local Pipeline(name, trigger) = {
kind: "pipeline",
name: name,
trigger: trigger,
steps: [
Cache('restore-cache', { mount: ['./node_modules', '/drone/docker' ], restore: true }),
{ name: 'prebuild',
image: 'shynome/npm-build',
commands: [
'npm-install',
'npm run preversion',
'npm run prebuild',
'npm run set_tags'
]
},
Cache('rebuild-npm-cache', { mount: ['./node_modules'], rebuild: true }),
{ name: 'docker_publish',
image: 'plugins/docker',
settings: {
repo: '${DRONE_REPO%%-docker}',
dockerfile: 'Dockerfile',
storage_path: '/drone/docker'
},
environment: {
DOCKER_USERNAME: { from_secret: 'docker_username' },
DOCKER_PASSWORD: { from_secret: 'docker_password' }
}
},
Cache('rebuild-docker-cache', { mount: ['/drone/docker'], rebuild: true }),
{ name: 'report',
image: 'shynome/alpine-drone-ci',
when: { status: ['failure'] },
environment: {
REPORT_HOOK: { from_secret: 'report_hook' }
},
settings: { deploy: 'report' }
}
],
volumes: [
{
name: 'cache',
host: { path: '/tmp/cache' },
},
],
};
[
Pipeline("dev",{ branch: [ 'dev' ], event: [ 'push' ] }),
Pipeline("tag",{ event: [ 'tag' ] })
]
but there is an error when I use command drone jsonnet --stream
generate .drone.yml
and push it to repo,
Drone Server
report this
yaml: line 80: could not find expected ':'
but when I append a new white line to .drone.yml
and push again, the error is disappear.