CircleCI-字符串中的正则表达式过滤匹配

时间:2019-04-24 21:45:33

标签: circleci

我正在尝试进行过滤,以确保分支中具有jira票证名称。票证名称可以在分支机构名称中的任何位置。

      - uploadToJira:
          requires:
            - testDebug
            - testRelease
          filters:
            branches:
              only: /.*(jira|JIRA)-\d+.*/

这应该与feature-JIRA-18889-testbug-JIRA-2344jira-1233之类的名称匹配,但似乎不匹配(尽管在Java中使用相同的正则表达式)。我在做什么错了?

更新:正则表达式/^pull.*/可以正常工作,告诉我它与分支的请求请求名称匹配(这是circleci在检查代码时使用的名称)。这似乎是circleci中的错误,因为pull/383并没有为您提供足够的信息来匹配分支名称。他们都一样。

1 个答案:

答案 0 :(得分:1)

由于PR来自派生的存储库,因此不匹配。仅当分支匹配来自非分支存储库中的PR时,分支匹配才起作用。

@halfer上面的建议是不过滤并让脚本本身确定是否应该运行是我们最终要做的事情。

是这样的:

import React, { Component } from 'react';
import styles from "../Style/styles";
import firebase from "react-native-firebase";
import ImagePicker from "react-native-image-picker";
import { View, Text, StyleSheet, TextInput, ScrollView, KeyboardAvoidingView, TouchableOpacity, Image } from 'react-native';

// create a component

class Order extends Component {
    constructor(props) {
        super(props);
        this.state = {
            userId: null,
            nameOfProblem: '',
            description: '',
            imageOfPrblem: '',
            timeDate: {},
            providerId: this.props.navigation.dangerouslyGetParent().getParam('providerId'),
        }
    }
    componentDidMount() {
        const userId = firebase.auth().currentUser.uid;
        this.setState({ userId });
    }
    handleOrder = () => {
        const { nameOfProblem, description, userId, imageOfPrblem, providerId } = this.state;
        const PushData = firebase.database().ref("request/" + providerId + "/" + userId + "/orders/");
        const ref = firebase.storage().ref("users/" + userId + "/UserImageOrders/" + path);
        let file = imageOfPrblem.uri;
        const path = "img_" + imageOfPrblem.fileName;
        if (file) {
            return (
                PushData.update({
                    nameOfProblem: nameOfProblem,
                    description: description,
                    // ...this.state.nameOfProblem,
                    // ...this.state.description,
                    imageOfPrblem: imageOfPrblem
                }).then(() => {
                    ref.put(file).then(() => {
                        console.log("File uploaded..")
                        setTimeout(() => {
this.props.navigation.navigate("Home"); // not working and get me back to Map screen, but when i navigate to other screen it's work fine!
                        }, 3000);
                    });
                })
            )
        }
        else {
            return (
                PushData.push({
                    nameOfProblem: nameOfProblem,
                    description: description,
                }).then(() => {
                    setTimeout(() => {
                        this.props.navigation.navigate("Home"); // Not work
                    }, 3000);
                })
            )
        }
        // else {

        // }
    }

    handleImages = () => {
        const options = {
            title: "Select Images!",
            storageOptions: {
                skipBackup: true,
                path: "images"
            }
        };
        ImagePicker.showImagePicker(options, response => {
            console.log("Response = ", response);
            if (response.uri) {
                this.setState({ imageOfPrblem: response });
            }
            if (response.didCancel) {
                console.log("User cancelled image picker");
            } else if (response.error) {
                console.log("ImagePicker Error: ", response.error);
            } else if (response.customButton) {
                console.log("User tapped custom button: ", response.customButton);
                alert(response.customButton);
            }
        });
    };

    render() {
        const { nameOfProblem, description, imageOfPrblem, timeDate } = this.state;
        const { getParam } = this.props.navigation.dangerouslyGetParent();
        const providerId = getParam('providerId');
        const providerName = getParam('providerName');
        return (
            <ScrollView scrollEnabled={true}>
                <KeyboardAvoidingView behavior="padding" keyboardVerticalOffset={70}>
                    <View style={[styles.container, { marginTop: 20 }]}>
                        <Text>Send Order To: {JSON.stringify(providerName)}, ID:{JSON.stringify(providerId)}</Text>

                        <TextInput
                            style={styles.textInput}
                            placeholder="Name of Problem"
                            value={nameOfProblem}
                            onChangeText={(nameOfProblem) => this.setState({ nameOfProblem })}
                            returnKeyType="next"
                            returnKeyLabel="next"
                        />

                        <TextInput
                            style={[styles.textInput, {
                                borderRadius: 5,
                                borderWidth: 1,
                                height: 120,
                                fontSize: 16,
                                padding: 10,
                                marginTop: 8
                            }]}
                            placeholder="Description"
                            multiline={true}
                            numberOfLines={12}
                            textAlignVertical="top"
                            value={description}
                            onChangeText={(description) => this.setState({ description })}
                            returnKeyType="next"
                            returnKeyLabel="next"
                        />

                        <TouchableOpacity onPress={this.handleImages}>
                            <View
                                style={{
                                    backgroundColor: "#DBDBDB",
                                    borderRadius: 100,
                                    alignSelf: "center",
                                    margin: 10,
                                    paddingBottom: 2,
                                    width: 120,
                                    height: 120
                                }}
                            >
                                <Text
                                    style={{
                                        position: "absolute",
                                        zIndex: 1,
                                        fontSize: 40,
                                        top: 67,
                                        color: "#1567d3",
                                        left: 99
                                    }}
                                >
                                    +
                                </Text>
                                <Image
                                    source={{ uri: imageOfPrblem.uri }}
                                    style={[styles.uploadAvatar, { borderRadius: 100 }]}
                                    resizeMode="cover"
                                />

                            </View>
                        </TouchableOpacity>
                        <TouchableOpacity
                            style={[styles.button, { backgroundColor: "#1567d3" }]}
                            onPress={this.handleOrder}
                        >
                            <Text style={{ color: "#fff", fontSize: 18 }}>Send</Text>
                        </TouchableOpacity>
                    </View>
                </KeyboardAvoidingView>
            </ScrollView>
        );
    }

}

// define your styles

//make this component available to the app
export default Order;